Compare commits
No commits in common. "6e5b4e1921a014d5dee3c9d01b4d80dceca8ff4e" and "cae16fbae25055d9bf8244238c384c61902aff07" have entirely different histories.
6e5b4e1921
...
cae16fbae2
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"ai_scheduler/internal/entitys"
|
"ai_scheduler/internal/entitys"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerTool struct {
|
type ZltxOrderAfterSaleResellerTool struct {
|
||||||
|
|
@ -23,7 +22,7 @@ func (t *ZltxOrderAfterSaleResellerTool) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerTool) Description() string {
|
func (t *ZltxOrderAfterSaleResellerTool) Description() string {
|
||||||
return "直连天下下游分销商普充订单售后工具"
|
return "直连天下上游供应商售后工具"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerTool) Definition() entitys.ToolDefinition {
|
func (t *ZltxOrderAfterSaleResellerTool) Definition() entitys.ToolDefinition {
|
||||||
|
|
@ -33,17 +32,17 @@ func (t *ZltxOrderAfterSaleResellerTool) Definition() entitys.ToolDefinition {
|
||||||
Name: t.Name(),
|
Name: t.Name(),
|
||||||
Description: t.Description(),
|
Description: t.Description(),
|
||||||
Parameters: map[string]interface{}{
|
Parameters: map[string]interface{}{
|
||||||
// "type": "object",
|
"type": "object",
|
||||||
// "properties": map[string]interface{}{
|
"properties": map[string]interface{}{
|
||||||
// "orderType": map[string]interface{}{
|
"orderType": map[string]interface{}{
|
||||||
// "type": "integer",
|
"type": "integer",
|
||||||
// "description": "售后订单类型",
|
"description": "售后订单类型",
|
||||||
// },
|
},
|
||||||
// "orderNumber": map[string]interface{}{
|
"orderNumber": map[string]interface{}{
|
||||||
// "type": "string",
|
"type": "string",
|
||||||
// "description": "售后订单号",
|
"description": "售后订单号",
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// "required": []string{"orderType", "orderNumber"},
|
// "required": []string{"orderType", "orderNumber"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -51,15 +50,13 @@ func (t *ZltxOrderAfterSaleResellerTool) Definition() entitys.ToolDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerRequest struct {
|
type ZltxOrderAfterSaleResellerRequest struct {
|
||||||
OrderNumber []string `json:"orderNumber"` // 订单号
|
OrderNumber string `json:"orderNumber"` // 订单号
|
||||||
|
SerialNumber string `json:"serialNumber"` // 流水号
|
||||||
Account string `json:"account"` // 充值账号
|
Account string `json:"account"` // 充值账号
|
||||||
OrderTimeStart string `json:"orderTimeStart"` // 订单执行开始时间
|
OrderTimeStart string `json:"orderTimeStart"` // 订单执行开始时间
|
||||||
OrderTimeEnd string `json:"orderTimeEnd"` // 订单执行结束时间
|
OrderTimeEnd string `json:"orderTimeEnd"` // 订单执行结束时间
|
||||||
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
|
|
||||||
AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
|
|
||||||
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
||||||
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
|
AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
|
||||||
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerResponse struct {
|
type ZltxOrderAfterSaleResellerResponse struct {
|
||||||
|
|
@ -94,13 +91,13 @@ func (t *ZltxOrderAfterSaleResellerTool) Execute(ctx context.Context, requireDat
|
||||||
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
|
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(req.OrderNumber) == 0 && (req.Account == "" || req.OrderTimeStart == "") {
|
// if req.OrderNumber == "" {
|
||||||
return fmt.Errorf("订单号 和 充值账号&订单执行时间 不能同时为空")
|
// return fmt.Errorf("orderType and orderNumber are required")
|
||||||
}
|
// }
|
||||||
return t.checkZltxOrderAfterSaleReseller(req, requireData)
|
return t.checkZltxOrderAfterSaleReseller(req.OrderNumber, requireData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerTool) checkZltxOrderAfterSaleReseller(req ZltxOrderAfterSaleResellerRequest, requireData *entitys.RequireData) error {
|
func (t *ZltxOrderAfterSaleResellerTool) checkZltxOrderAfterSaleReseller(orderNumber string, requireData *entitys.RequireData) error {
|
||||||
// req := l_request.Request{
|
// req := l_request.Request{
|
||||||
// Url: t.config.BaseURL,
|
// Url: t.config.BaseURL,
|
||||||
// Headers: map[string]string{
|
// Headers: map[string]string{
|
||||||
|
|
@ -124,8 +121,6 @@ func (t *ZltxOrderAfterSaleResellerTool) checkZltxOrderAfterSaleReseller(req Zlt
|
||||||
// if resp.Code != 0 {
|
// if resp.Code != 0 {
|
||||||
// return fmt.Errorf("check failed: %s", resp.Msg)
|
// return fmt.Errorf("check failed: %s", resp.Msg)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// === mock start ===
|
|
||||||
resp := ZltxOrderAfterSaleResellerResponse{
|
resp := ZltxOrderAfterSaleResellerResponse{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "success",
|
Msg: "success",
|
||||||
|
|
@ -170,12 +165,6 @@ func (t *ZltxOrderAfterSaleResellerTool) checkZltxOrderAfterSaleReseller(req Zlt
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.OrderNumber) == 1 {
|
|
||||||
resp.Data = resp.Data[:1]
|
|
||||||
}
|
|
||||||
// === mock end ===
|
|
||||||
|
|
||||||
jsonByte, err := json.Marshal(resp)
|
jsonByte, err := json.Marshal(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -1,182 +0,0 @@
|
||||||
package tools
|
|
||||||
|
|
||||||
import (
|
|
||||||
"ai_scheduler/internal/config"
|
|
||||||
"ai_scheduler/internal/entitys"
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerBatchTool struct {
|
|
||||||
config config.ToolConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewZltxOrderAfterSaleResellerBatchTool 创建售后订单预检工具
|
|
||||||
func NewZltxOrderAfterSaleResellerBatchTool(config config.ToolConfig) *ZltxOrderAfterSaleResellerBatchTool {
|
|
||||||
return &ZltxOrderAfterSaleResellerBatchTool{config: config}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Name 返回工具名称
|
|
||||||
func (t *ZltxOrderAfterSaleResellerBatchTool) Name() string {
|
|
||||||
return "zltxOrderAfterSaleResellerBatch"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerBatchTool) Description() string {
|
|
||||||
return "直连天下下游分销商批充订单售后工具"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerBatchTool) Definition() entitys.ToolDefinition {
|
|
||||||
return entitys.ToolDefinition{
|
|
||||||
Type: "function",
|
|
||||||
Function: entitys.FunctionDef{
|
|
||||||
Name: t.Name(),
|
|
||||||
Description: t.Description(),
|
|
||||||
Parameters: map[string]interface{}{
|
|
||||||
// "type": "object",
|
|
||||||
// "properties": map[string]interface{}{
|
|
||||||
// "orderType": map[string]interface{}{
|
|
||||||
// "type": "integer",
|
|
||||||
// "description": "售后订单类型",
|
|
||||||
// },
|
|
||||||
// "orderNumber": map[string]interface{}{
|
|
||||||
// "type": "string",
|
|
||||||
// "description": "售后订单号",
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// "required": []string{"orderType", "orderNumber"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerBatchRequest struct {
|
|
||||||
OrderNumber []string `json:"orderNumber"` // 订单号
|
|
||||||
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
|
|
||||||
AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
|
|
||||||
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
|
||||||
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
|
|
||||||
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
|
|
||||||
}
|
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerBatchResponse struct {
|
|
||||||
Code int `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Data []ZltxOrderAfterSaleResellerBatchData `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ZltxOrderAfterSaleResellerBatchData struct {
|
|
||||||
OrderType int `json:"orderType"`
|
|
||||||
OrderNumber string `json:"orderNumber"`
|
|
||||||
OrderAmount float64 `json:"orderAmount"`
|
|
||||||
OrderPrice float64 `json:"orderPrice"`
|
|
||||||
SignCompany int `json:"signCompany"`
|
|
||||||
OrderQuantity int `json:"orderQuantity"`
|
|
||||||
ResellerID int `json:"resellerId"`
|
|
||||||
ResellerName string `json:"resellerName"`
|
|
||||||
OurProductID int `json:"ourProductId"`
|
|
||||||
OurProductTitle string `json:"ourProductTitle"`
|
|
||||||
Account []string `json:"account"`
|
|
||||||
Platforms map[int]string `json:"platforms"`
|
|
||||||
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
|
|
||||||
Remark string `json:"remark"` // 售后原因
|
|
||||||
AfterAmount float64 `json:"afterAmount"` // 售后金额
|
|
||||||
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
|
|
||||||
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
|
|
||||||
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerBatchTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
|
|
||||||
var req ZltxOrderAfterSaleResellerBatchRequest
|
|
||||||
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if len(req.OrderNumber) == 0 {
|
|
||||||
return fmt.Errorf("批充订单号不能为空")
|
|
||||||
}
|
|
||||||
return t.checkZltxOrderAfterSaleResellerBatch(req, requireData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleResellerBatchTool) checkZltxOrderAfterSaleResellerBatch(req ZltxOrderAfterSaleResellerBatchRequest, requireData *entitys.RequireData) error {
|
|
||||||
// req := l_request.Request{
|
|
||||||
// Url: t.config.BaseURL,
|
|
||||||
// Headers: map[string]string{
|
|
||||||
// "Authorization": fmt.Sprintf("Bearer %s", requireData.Auth),
|
|
||||||
// },
|
|
||||||
// Method: "POST",
|
|
||||||
// Data: map[string]string{
|
|
||||||
// // "orderType": fmt.Sprintf("%d", orderType),
|
|
||||||
// "orderNumber": orderNumber,
|
|
||||||
// },
|
|
||||||
// }
|
|
||||||
// res, err := req.Send()
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// // 解析响应
|
|
||||||
// var resp ZltxOrderAfterSaleResellerBatchResponse
|
|
||||||
// if err := json.Unmarshal(res.Content, &resp); err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// if resp.Code != 0 {
|
|
||||||
// return fmt.Errorf("check failed: %s", resp.Msg)
|
|
||||||
// }
|
|
||||||
|
|
||||||
// === mock start ===
|
|
||||||
resp := ZltxOrderAfterSaleResellerBatchResponse{
|
|
||||||
Code: 0,
|
|
||||||
Msg: "success",
|
|
||||||
Data: []ZltxOrderAfterSaleResellerBatchData{
|
|
||||||
{
|
|
||||||
OrderType: 1,
|
|
||||||
OrderNumber: "846784115378364417",
|
|
||||||
OrderAmount: 0.1,
|
|
||||||
OrderPrice: 0.1,
|
|
||||||
SignCompany: 1,
|
|
||||||
OrderQuantity: 1,
|
|
||||||
ResellerID: 23329,
|
|
||||||
ResellerName: "分销商23329",
|
|
||||||
OurProductID: 106,
|
|
||||||
OurProductTitle: "爱奇艺黄金会员周卡",
|
|
||||||
Account: []string{"15516353308"},
|
|
||||||
Platforms: map[int]string{4: "爱奇艺"},
|
|
||||||
AfterType: 1,
|
|
||||||
Remark: "测试售后",
|
|
||||||
AfterAmount: 50,
|
|
||||||
ResponsibleType: 1,
|
|
||||||
IsExistsAfterSale: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
OrderType: 101,
|
|
||||||
OrderNumber: "846052057729867777",
|
|
||||||
OrderAmount: 23,
|
|
||||||
OrderPrice: 23,
|
|
||||||
SignCompany: 1,
|
|
||||||
OrderQuantity: 1,
|
|
||||||
ResellerID: 25629,
|
|
||||||
ResellerName: "二期财务分销商简称",
|
|
||||||
OurProductID: 104,
|
|
||||||
OurProductTitle: "优酷年卡",
|
|
||||||
Account: []string{"18380416326"},
|
|
||||||
Platforms: map[int]string{1: "爱瓦力"},
|
|
||||||
AfterType: 2,
|
|
||||||
Remark: "测试售后2",
|
|
||||||
AfterAmount: 30,
|
|
||||||
ResponsibleType: 2,
|
|
||||||
IsExistsAfterSale: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(req.OrderNumber) == 1 {
|
|
||||||
resp.Data = resp.Data[:1]
|
|
||||||
}
|
|
||||||
// === mock end ===
|
|
||||||
|
|
||||||
jsonByte, err := json.Marshal(resp)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
entitys.ResJson(requireData.Ch, t.Name(), string(jsonByte))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"ai_scheduler/internal/entitys"
|
"ai_scheduler/internal/entitys"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ZltxOrderAfterSaleSupplierTool struct {
|
type ZltxOrderAfterSaleSupplierTool struct {
|
||||||
|
|
@ -51,13 +50,13 @@ func (t *ZltxOrderAfterSaleSupplierTool) Definition() entitys.ToolDefinition {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZltxOrderAfterSaleSupplierRequest struct {
|
type ZltxOrderAfterSaleSupplierRequest struct {
|
||||||
SerialNumber []string `json:"serialNumber"` // 流水号
|
OrderNumber string `json:"orderNumber"` // 订单号
|
||||||
|
SerialNumber string `json:"serialNumber"` // 流水号
|
||||||
Account string `json:"account"` // 充值账号
|
Account string `json:"account"` // 充值账号
|
||||||
OrderTimeStart string `json:"orderTimeStart"` // 订单执行开始时间
|
OrderTimeStart string `json:"orderTimeStart"` // 订单执行开始时间
|
||||||
OrderTimeEnd string `json:"orderTimeEnd"` // 订单执行结束时间
|
OrderTimeEnd string `json:"orderTimeEnd"` // 订单执行结束时间
|
||||||
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
AfterSalesReason string `json:"afterSalesReason"` // 售后原因
|
||||||
AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
|
AfterSalesPrice string `json:"afterSalesPrice"` // 售后金额
|
||||||
AfterType int `json:"afterType"` // 售后类型 1.加款 2.扣款
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ZltxOrderAfterSaleSupplierResponse struct {
|
type ZltxOrderAfterSaleSupplierResponse struct {
|
||||||
|
|
@ -89,13 +88,13 @@ func (t *ZltxOrderAfterSaleSupplierTool) Execute(ctx context.Context, requireDat
|
||||||
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
|
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(req.SerialNumber) == 0 && (req.Account == "" || req.OrderTimeStart == "") {
|
// if req.OrderNumber == "" {
|
||||||
return fmt.Errorf("充值流水号 和 充值账号&订单执行时间 不能同时为空")
|
// return fmt.Errorf("orderType and orderNumber are required")
|
||||||
}
|
// }
|
||||||
return t.checkZltxOrderAfterSaleSupplier(req, requireData)
|
return t.checkZltxOrderAfterSaleSupplier(req.OrderNumber, requireData)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ZltxOrderAfterSaleSupplierTool) checkZltxOrderAfterSaleSupplier(req ZltxOrderAfterSaleSupplierRequest, requireData *entitys.RequireData) error {
|
func (t *ZltxOrderAfterSaleSupplierTool) checkZltxOrderAfterSaleSupplier(orderNumber string, requireData *entitys.RequireData) error {
|
||||||
// req := l_request.Request{
|
// req := l_request.Request{
|
||||||
// Url: t.config.BaseURL,
|
// Url: t.config.BaseURL,
|
||||||
// Headers: map[string]string{
|
// Headers: map[string]string{
|
||||||
|
|
@ -119,12 +118,23 @@ func (t *ZltxOrderAfterSaleSupplierTool) checkZltxOrderAfterSaleSupplier(req Zlt
|
||||||
// if resp.Code != 0 {
|
// if resp.Code != 0 {
|
||||||
// return fmt.Errorf("check failed: %s", resp.Msg)
|
// return fmt.Errorf("check failed: %s", resp.Msg)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// === mock start ===
|
|
||||||
resp := ZltxOrderAfterSaleSupplierResponse{
|
resp := ZltxOrderAfterSaleSupplierResponse{
|
||||||
Code: 0,
|
Code: 0,
|
||||||
Msg: "success",
|
Msg: "success",
|
||||||
Data: []ZltxOrderAfterSaleSupplierData{
|
Data: []ZltxOrderAfterSaleSupplierData{
|
||||||
|
// {
|
||||||
|
// "serialNumber": "847465394004430849",
|
||||||
|
// "platformName": "爱奇艺",
|
||||||
|
// "signCompany": 1,
|
||||||
|
// "platformProductName": "爱奇艺官方周卡",
|
||||||
|
// "platformPrice": 6,
|
||||||
|
// "terminalAccount": "15516353308",
|
||||||
|
// "status": 1,
|
||||||
|
// "platformProductId": 2,
|
||||||
|
// "platformId": 4,
|
||||||
|
// "signCompanyName": "成都蓝色兄弟网络科技有限公司",
|
||||||
|
// "executeTime": 1763961931
|
||||||
|
// }
|
||||||
{
|
{
|
||||||
SerialNumber: "847465394004430849",
|
SerialNumber: "847465394004430849",
|
||||||
PlatformName: "爱奇艺",
|
PlatformName: "爱奇艺",
|
||||||
|
|
@ -161,12 +171,6 @@ func (t *ZltxOrderAfterSaleSupplierTool) checkZltxOrderAfterSaleSupplier(req Zlt
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.SerialNumber) == 1 {
|
|
||||||
resp.Data = resp.Data[:1]
|
|
||||||
}
|
|
||||||
// === mock end ===
|
|
||||||
|
|
||||||
jsonByte, err := json.Marshal(resp)
|
jsonByte, err := json.Marshal(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue