Compare commits

..

No commits in common. "8895f29963b5451cfdc789d9ff5742955ea638b4" and "a844d12979c5d69173ae81c8a87cfbbc89e60479" have entirely different histories.

9 changed files with 49 additions and 104 deletions

View File

@ -7,7 +7,7 @@ ollama:
base_url: "http://127.0.0.1:11434"
model: "qwen3-coder:480b-cloud"
generate_model: "qwen3-coder:480b-cloud"
vl_model: "qwen2.5vl:7b"
vl_model: "qwen2.5vl:3b"
timeout: "120s"
level: "info"
format: "json"

View File

@ -16,7 +16,7 @@ CONFIG_FILE="config/config.yaml"
BRANCH="master"
if [ "$MODE" = "dev" ]; then
CONFIG_FILE="config/config_test.yaml"
BRANCH="test"
BRANCH="v2"
fi
git fetch origin

View File

@ -1,7 +1,6 @@
package biz
import (
"ai_scheduler/internal/data/constants"
errors "ai_scheduler/internal/data/error"
"ai_scheduler/internal/data/impl"
"ai_scheduler/internal/data/model"
@ -9,11 +8,10 @@ import (
"ai_scheduler/internal/pkg/l_request"
"context"
"encoding/json"
"gorm.io/gorm/utils"
"net/http"
"strconv"
"gorm.io/gorm/utils"
"xorm.io/builder"
"ai_scheduler/internal/config"
@ -35,9 +33,9 @@ func NewTaskBiz(conf *config.Config, taskRepo *impl.TaskImpl) *TaskBiz {
func (t *TaskBiz) TaskList(ctx context.Context, req *entitys.TaskRequest, auth string) (list []model.AiTask, err error) {
tasks := make([]model.AiTask, 0)
cond := builder.NewCond()
cond = cond.And(builder.Eq{"status": constants.Enable})
cond = cond.And(builder.Eq{"status": 1})
cond = cond.And(builder.Eq{"sys_id": req.SysId})
cond = cond.And(builder.Eq{"is_show": constants.IsSHOW})
err = t.taskRepo.GetRangeToMapStruct(&cond, &tasks)
codes, err := t.GetUserPermission(req, auth)
@ -57,16 +55,20 @@ func (t *TaskBiz) TaskList(ctx context.Context, req *entitys.TaskRequest, auth s
// 从统一登录平台获取用户权限
func (t *TaskBiz) GetUserPermission(req *entitys.TaskRequest, auth string) (codes []string, err error) {
var (
request l_request.Request
)
request := l_request.Request{
Method: "GET",
Url: t.conf.PermissionConfig.PermissionURL + strconv.Itoa(int(req.SysId)),
Headers: map[string]string{
// 构建请求URL
request.Url = t.conf.PermissionConfig.PermissionURL + strconv.Itoa(int(req.SysId))
request.Method = "GET"
request.Headers = map[string]string{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
"Accept": "application/json, text/plain, */*",
"Authorization": auth,
},
}
// 发送请求
res, err := request.Send()
if err != nil {
@ -82,7 +84,7 @@ func (t *TaskBiz) GetUserPermission(req *entitys.TaskRequest, auth string) (code
type resp struct {
Codes []string `json:"codes"`
}
// 解析响应体s
// 解析响应体
var respBody resp
err = json.Unmarshal([]byte(res.Text), &respBody)
if err != nil {

View File

@ -1,11 +0,0 @@
package constants
const (
IsSHOW = 1
NotShow = 2
)
const (
Enable = 1
Disable = 2
)

View File

@ -12,21 +12,19 @@ const TableNameAiTask = "ai_task"
// AiTask mapped from table <ai_task>
type AiTask struct {
TaskID int32 `gorm:"column:task_id;primaryKey;autoIncrement:true" json:"task_id"`
TaskID int32 `gorm:"column:task_id;primaryKey" json:"task_id"`
SysID int32 `gorm:"column:sys_id;not null" json:"sys_id"`
Name string `gorm:"column:name;not null" json:"name"`
Index string `gorm:"column:index;not null" json:"index"`
Desc string `gorm:"column:desc;not null" json:"desc"`
UseCase string `gorm:"column:use_case;not null;comment:适用场景" json:"use_case"` // 适用场景
TempPrompt string `gorm:"column:temp_prompt;not null;comment:提示词模板" json:"temp_prompt"` // 提示词模板
Type int32 `gorm:"column:type;not null;default:1;comment:类型1api,2:知识库" json:"type"` // 类型1api,2:知识库
Type int32 `gorm:"column:type;not null;comment:类型1api,2:知识库" json:"type"` // 类型1api,2:知识库
Config string `gorm:"column:config" json:"config"`
TagType int32 `gorm:"column:tag_type;comment:标签类型1.AI日常 2.AI查询 3.AI执行" json:"tag_type"` // 标签类型1.AI日常 2.AI查询 3.AI执行
CreateAt time.Time `gorm:"column:create_at;default:CURRENT_TIMESTAMP" json:"create_at"`
UpdatedAt time.Time `gorm:"column:updated_at;default:CURRENT_TIMESTAMP" json:"updated_at"`
IsShow int32 `gorm:"column:is_show;not null;default:1;comment:是否展示1为展示2为不展示" json:"is_show"` // 是否展示1为展示2为不展示
UpdateAt time.Time `gorm:"column:update_at;default:CURRENT_TIMESTAMP" json:"update_at"`
Status int32 `gorm:"column:status;not null;default:1" json:"status"`
DeleteAt time.Time `gorm:"column:delete_at" json:"delete_at"`
UseCase string `gorm:"column:use_case;not null" json:"use_case"` // 适用场景
TagType int32 `gorm:"column:tag_type;not null;default:1" json:"tag_type"` // 标签类型 1.AI日常 2.AI查询 3.AI执行
}
// TableName AiTask's table name

View File

@ -26,9 +26,3 @@ func StringToInt(s string) int {
i, _ := strconv.Atoi(s)
return i
}
// string 转 float64
func StringToFloat64(s string) float64 {
i, _ := strconv.ParseFloat(s, 64)
return i
}

View File

@ -68,7 +68,7 @@ type OrderAfterSaleResellerData struct {
Platforms map[int]string `json:"platforms"`
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
Remark string `json:"remark"` // 售后原因
AfterAmount float64 `json:"afterAmount"` // 售后金额
AfterAmount string `json:"afterAmount"` // 售后金额
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
@ -107,7 +107,8 @@ type OrderAfterSaleResellerApiExtItem struct {
func (t *OrderAfterSaleResellerTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
var req OrderAfterSaleResellerRequest
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
return fmt.Errorf("解析参数失败,请重试或联系管理员")
entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员")
return err
}
if len(req.OrderNumber) == 0 && len(req.Account) == 0 {
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
@ -189,11 +190,6 @@ func (t *OrderAfterSaleResellerTool) checkOrderAfterSaleReseller(toolReq OrderAf
return fmt.Errorf("订单号 和 充值账号 不能同时为空")
}
// 未查询到相应售后订单,请核实提供信息是否正确
if len(orderList) == 0 {
return fmt.Errorf("未查询到相应售后订单,请核实提供信息是否正确")
}
toolResp := OrderAfterSaleResellerResponse{
Code: 0,
Msg: "Success",
@ -235,17 +231,6 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
// 转换数据
for _, item := range resp.Data.Data {
// 处理方式
afterType := util.StringToInt(originInput.AfterType)
if afterType == 0 {
afterType = 1 // 默认退款
}
// 费用承担者
responsibleType := util.StringToInt(originInput.ResponsibleType)
if responsibleType == 0 {
responsibleType = 4 // 默认无
}
orderList = append(orderList, &OrderAfterSaleResellerData{
OrderType: item.OrderType,
OrderNumber: item.OrderNumber,
@ -259,10 +244,10 @@ func (t *OrderAfterSaleResellerTool) getAfterSaleResellerList(headers map[string
OurProductTitle: item.OurProductTitle,
Account: item.Account,
Platforms: item.Platforms,
AfterType: afterType,
AfterType: util.StringToInt(originInput.AfterType),
Remark: originInput.AfterSalesReason,
AfterAmount: util.StringToFloat64(originInput.AfterSalesPrice),
ResponsibleType: responsibleType,
AfterAmount: originInput.AfterSalesPrice,
ResponsibleType: util.StringToInt(originInput.ResponsibleType),
ResponsiblePerson: originInput.ResponsiblePerson,
})
}

View File

@ -64,7 +64,7 @@ type OrderAfterSaleResellerBatchData struct {
Platforms map[int]string `json:"platforms"`
AfterType int `json:"afterType"` // 处理方式 1.退款 2.扣款
Remark string `json:"remark"` // 售后原因
AfterAmount float64 `json:"afterAmount"` // 售后金额
AfterAmount string `json:"afterAmount"` // 售后金额
ResponsibleType int `json:"responsibleType"` // 费用承担者 1.供应商 2.商务 3.公司 4.无
ResponsiblePerson string `json:"responsiblePerson"` // 费用承担供应商
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
@ -103,7 +103,8 @@ type OrderAfterSaleResellerBatchApiExtItem struct {
func (t *OrderAfterSaleResellerBatchTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
var req OrderAfterSaleResellerBatchRequest
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
return fmt.Errorf("解析参数失败,请重试或联系管理员")
entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员")
return err
}
if len(req.OrderNumber) == 0 {
return fmt.Errorf("批充订单号不能为空")
@ -136,10 +137,7 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
return err
}
if resp.Code != 200 {
return fmt.Errorf("售后订单查询异常: %s", resp.Error)
}
if len(resp.Data.Data) == 0 {
return fmt.Errorf("未查询到相应售后订单,请核实订单号是否正确")
return fmt.Errorf("after sale supplier failed: %s", resp.Error)
}
toolResp := OrderAfterSaleResellerBatchResponse{
@ -150,17 +148,6 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
// 转换数据
for _, item := range resp.Data.Data {
// 处理方式
afterType := util.StringToInt(toolReq.AfterType)
if afterType == 0 {
afterType = 1 // 默认退款
}
// 费用承担者
responsibleType := util.StringToInt(toolReq.ResponsibleType)
if responsibleType == 0 {
responsibleType = 4 // 默认无
}
toolResp.Data = append(toolResp.Data, &OrderAfterSaleResellerBatchData{
OrderType: item.OrderType,
OrderNumber: item.OrderNumber,
@ -174,10 +161,10 @@ func (t *OrderAfterSaleResellerBatchTool) checkOrderAfterSaleResellerBatch(toolR
OurProductTitle: item.OurProductTitle,
Account: item.Account,
Platforms: item.Platforms,
AfterType: afterType,
AfterType: util.StringToInt(toolReq.AfterType),
Remark: toolReq.AfterSalesReason,
AfterAmount: util.StringToFloat64(toolReq.AfterSalesPrice),
ResponsibleType: responsibleType,
AfterAmount: toolReq.AfterSalesPrice,
ResponsibleType: util.StringToInt(toolReq.ResponsibleType),
ResponsiblePerson: toolReq.ResponsiblePerson,
})
}

View File

@ -64,7 +64,7 @@ type OrderAfterSaleSupplierData struct {
PlatformID int `json:"platformId"` // 上游平台id
SignCompanyName string `json:"signCompanyName"` // 签约主体名称
Reason string `json:"reason"` // 售后原因
SalePrice float64 `json:"salePrice"` // 售后金额
SalePrice string `json:"salePrice"` // 售后金额
SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款
ExecuteTime int `json:"executeTime"` // 流水创建时间
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
@ -101,7 +101,8 @@ type OrderAfterSaleSupplierApiExtItem struct {
func (t *OrderAfterSaleSupplierTool) Execute(ctx context.Context, requireData *entitys.RequireData) error {
var req OrderAfterSaleSupplierRequest
if err := json.Unmarshal([]byte(requireData.Match.Parameters), &req); err != nil {
return fmt.Errorf("解析参数失败,请重试或联系管理员")
entitys.ResError(requireData.Ch, t.Name(), "解析参数失败,请重试或联系管理员")
return err
}
if len(req.SerialNumber) == 0 && len(req.Account) == 0 {
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
@ -181,11 +182,6 @@ func (t *OrderAfterSaleSupplierTool) checkOrderAfterSaleSupplier(toolReq OrderAf
return fmt.Errorf("充值流水号 和 充值账号 不能同时为空")
}
// 未查询到相应售后订单,请核实提供信息是否正确
if len(orderList) == 0 {
return fmt.Errorf("未查询到相应售后订单,请核实提供信息是否正确")
}
toolResp := OrderAfterSaleSupplierResponse{
Code: 0,
Msg: "Success",
@ -227,12 +223,6 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
// 转换数据
for _, item := range resp.Data.Data {
// 处理方式
afterType := util.StringToInt(originInput.AfterType)
if afterType == 0 {
afterType = 1 // 默认退款
}
orderList = append(orderList, &OrderAfterSaleSupplierData{
SerialNumber: item.SerialNumber,
PlatformName: item.PlatformName,
@ -245,8 +235,8 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
PlatformID: item.PlatformID,
SignCompanyName: item.SignCompanyName,
Reason: originInput.AfterSalesReason,
SalePrice: util.StringToFloat64(originInput.AfterSalesPrice),
SaleType: afterType,
SalePrice: originInput.AfterSalesPrice,
SaleType: util.StringToInt(originInput.AfterType),
})
}