Merge remote-tracking branch 'origin/master' into test
This commit is contained in:
commit
5a4dc13324
|
|
@ -5,6 +5,9 @@ server:
|
|||
|
||||
ollama:
|
||||
base_url: "http://172.17.0.1:11434"
|
||||
# model: "qwen3:8b"
|
||||
# generate_model: "qwen3:8b"
|
||||
# mapping_model: "qwen3:8b"
|
||||
model: "qwen3-coder:480b-cloud"
|
||||
generate_model: "qwen3-coder:480b-cloud"
|
||||
mapping_model: "deepseek-v3.2:cloud"
|
||||
|
|
|
|||
|
|
@ -301,8 +301,8 @@ func (r *Handle) HandleBot(ctx context.Context, rec *entitys.Recognize, task *en
|
|||
}
|
||||
var detailPage string
|
||||
entitys.ResLog(rec.Ch, task.Index, "需求记录完成")
|
||||
switch task.OutPutFormat {
|
||||
case entitys.OutPutFormatMarkdown:
|
||||
switch rec.OutPutScene {
|
||||
case entitys.OutPutSceneDingTalk:
|
||||
// 构建跳转链接
|
||||
detailPage = "[去查看](" + r.conf.Dingtalk.TableDemand.Url + ")"
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -253,16 +253,17 @@ func (g *GroupConfigBiz) handleMatch(ctx context.Context, rec *entitys.Recognize
|
|||
break
|
||||
}
|
||||
}
|
||||
rec.OutPutScene = entitys.OutPutSceneDingTalk
|
||||
if pointTask == nil || pointTask.Index == "other" {
|
||||
return g.otherTask(ctx, rec)
|
||||
}
|
||||
|
||||
switch constants.TaskType(pointTask.Type) {
|
||||
case constants.TaskTypeFunc:
|
||||
return g.handleTask(ctx, rec, pointTask)
|
||||
case constants.TaskTypeBot:
|
||||
return g.handle.HandleBot(ctx, rec, &entitys.Task{
|
||||
Index: pointTask.Index,
|
||||
OutPutFormat: entitys.OutPutFormatMarkdown,
|
||||
Index: pointTask.Index,
|
||||
})
|
||||
case constants.TaskTypeReport:
|
||||
return g.handleReport(ctx, rec, pointTask, groupConfig)
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func (w *statisticsOursProduct) formatContext(ctx context.Context, input *Statis
|
|||
Time: time.Now(),
|
||||
StartTime: startTime,
|
||||
EndTime: endTime,
|
||||
Title: fmt.Sprintf("截止 %s 亏损100以上我们的商品统计", endTimeStr),
|
||||
Title: fmt.Sprintf("截止 %s 电商系统亏损100以上我们的商品统计", endTimeStr),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,5 @@ type DingTalkBot struct {
|
|||
}
|
||||
|
||||
type Task struct {
|
||||
Index string `json:"bot_index"`
|
||||
OutPutFormat OutPutFormat `json:"out_put_format"`
|
||||
Index string `json:"bot_index"`
|
||||
}
|
||||
|
||||
type OutPutFormat string
|
||||
|
||||
const OutPutFormatMarkdown OutPutFormat = "markdown"
|
||||
const OutPutFormatHtml OutPutFormat = "html"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,14 @@ type Recognize struct {
|
|||
Ch chan Response
|
||||
Match *Match
|
||||
Ext []byte
|
||||
OutPutScene OutPutScene
|
||||
}
|
||||
|
||||
type OutPutScene string
|
||||
|
||||
const OutPutSceneDingTalk OutPutScene = "markdown"
|
||||
const OutPutFormatHtml OutPutScene = "html"
|
||||
|
||||
type TaskExt struct {
|
||||
Auth string `json:"auth"`
|
||||
Session string `json:"session"`
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ollama/ollama/api"
|
||||
)
|
||||
|
|
@ -43,11 +44,12 @@ func (c *Client) ToolSelect(ctx context.Context, messages []api.Message, tools [
|
|||
|
||||
// 构建聊天请求
|
||||
req := &api.ChatRequest{
|
||||
Model: c.config.Model,
|
||||
Messages: messages,
|
||||
Stream: new(bool), // 设置为false,不使用流式响应
|
||||
Think: &api.ThinkValue{Value: false},
|
||||
Tools: tools,
|
||||
Model: c.config.Model,
|
||||
Messages: messages,
|
||||
Stream: new(bool), // 设置为false,不使用流式响应
|
||||
Think: &api.ThinkValue{Value: false},
|
||||
Tools: tools,
|
||||
KeepAlive: &api.Duration{Duration: 24 * time.Hour},
|
||||
}
|
||||
err = c.client.Chat(ctx, req, func(resp api.ChatResponse) error {
|
||||
res = resp
|
||||
|
|
|
|||
|
|
@ -403,10 +403,6 @@ func (b *BbxtTools) GetProfitRankingSum(now time.Time) (report *ReportRes, err e
|
|||
|
||||
// GetStatisOfficialProductSum 销量同比分析
|
||||
func (b *BbxtTools) GetStatisOfficialProductSum(now time.Time, productName []string) (report *ReportRes, err error) {
|
||||
var productMap = make(map[string]int)
|
||||
for k, v := range productName {
|
||||
productMap[v] = k
|
||||
}
|
||||
ct := []string{
|
||||
time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()).Format("2006-01-02 15:04:05"),
|
||||
adjustedTime(now),
|
||||
|
|
@ -428,7 +424,11 @@ func (b *BbxtTools) GetStatisOfficialProductSum(now time.Time, productName []str
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
var total = make([][]string, len(ids))
|
||||
|
||||
// 创建临时map存储产品数据
|
||||
productDataMap := make(map[string][]string)
|
||||
var productNamesInResult []string
|
||||
|
||||
for _, v := range data.OfficialProductSum {
|
||||
var (
|
||||
yeterDatyDiff string
|
||||
|
|
@ -444,7 +444,8 @@ func (b *BbxtTools) GetStatisOfficialProductSum(now time.Time, productName []str
|
|||
} else {
|
||||
lastWeekDiff = fmt.Sprintf("%s↓%d", GreenStyle, v.HistoryTwoDiff)
|
||||
}
|
||||
total[productMap[v.OfficialProductName]] = []string{
|
||||
|
||||
rowData := []string{
|
||||
fmt.Sprintf("%s", v.OfficialProductName),
|
||||
fmt.Sprintf("%d", v.CurrentNum),
|
||||
fmt.Sprintf("%d", v.HistoryOneNum),
|
||||
|
|
@ -453,7 +454,20 @@ func (b *BbxtTools) GetStatisOfficialProductSum(now time.Time, productName []str
|
|||
lastWeekDiff,
|
||||
}
|
||||
|
||||
// 存储到map中,key为产品名
|
||||
productDataMap[v.OfficialProductName] = rowData
|
||||
productNamesInResult = append(productNamesInResult, v.OfficialProductName)
|
||||
}
|
||||
|
||||
// 按照productName的顺序构建total
|
||||
var total [][]string
|
||||
|
||||
for _, name := range productName {
|
||||
if rowData, exists := productDataMap[name]; exists {
|
||||
total = append(total, rowData)
|
||||
}
|
||||
}
|
||||
|
||||
timeCh := now.Format("1月2日15点")
|
||||
title := "截至" + timeCh + "销售同比分析"
|
||||
//总量生成excel
|
||||
|
|
|
|||
|
|
@ -79,14 +79,22 @@ func Test_GetStatisOfficialProductSumDecline(t *testing.T) {
|
|||
}
|
||||
|
||||
func Test_GetStatisOfficialProductSum(t *testing.T) {
|
||||
|
||||
run()
|
||||
configs := configConfig
|
||||
o, err := NewBbxtTools(nil, lsxd.NewLogin(configs, utils.NewRdb(configConfig)))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
s := "官方--美团外卖红包5元,官方--美团外卖红包10元,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡,官方--芒果-PC季卡,官方--芒果-PC月卡,官方--芒果-PC周卡,官方--腾讯-周卡,官方--优酷周卡,官方--QQ音乐-绿钻月卡,官方--爱奇艺-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡"
|
||||
report, err := o.GetStatisOfficialProductSum(time.Now(), strings.Split(s, ","))
|
||||
s := "官方--腾讯-周卡,官方--腾讯-月卡,官方--腾讯-季卡,官方--腾讯-年卡,官方--优酷周卡,官方--优酷月卡,官方--优酷季卡,官方--优酷年卡,官方--爱奇艺-周卡,官方--爱奇艺-月卡,官方--爱奇艺-季卡,官方--爱奇艺-年卡,官方--芒果-PC周卡,官方--芒果-PC月卡,官方--芒果-PC季卡,官方--美团外卖红包5元,官方--美团外卖红包10元,官方--QQ音乐-绿钻月卡,官方--饿了么超级会员月卡,官方--网易云黑胶vip月卡,官方--喜马拉雅巅峰会员月卡"
|
||||
now := time.Now()
|
||||
noon := time.Date(
|
||||
now.Year(),
|
||||
now.Month(),
|
||||
now.Day(),
|
||||
12, 0, 0, 0,
|
||||
now.Location(),
|
||||
)
|
||||
report, err := o.GetStatisOfficialProductSum(noon, strings.Split(s, ","))
|
||||
|
||||
t.Log(report, err)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.cdlsxd.cn/self-tools/l_request"
|
||||
"github.com/ollama/ollama/api"
|
||||
|
|
@ -77,14 +79,74 @@ type ZltxOrderDetailRequest struct {
|
|||
OrderNumber interface{} `json:"order_number"`
|
||||
}
|
||||
|
||||
//type ZltxOrderDetailResponse struct {
|
||||
// Code int `json:"code"`
|
||||
// Error string `json:"error"`
|
||||
// Data ZltxOrderDetailData `json:"data"`
|
||||
// Mes string `json:"mes"`
|
||||
//}
|
||||
|
||||
// ZltxOrderDetailResponse 直连天下订单详情响应
|
||||
type ZltxOrderDetailResponse struct {
|
||||
Code int `json:"code"`
|
||||
Error string `json:"error"`
|
||||
Data ZltxOrderDetailData `json:"data"`
|
||||
Mes string `json:"mes"`
|
||||
Code int `json:"code"`
|
||||
Data Data `json:"data"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
Direct *Direct `json:"direct"`
|
||||
Order *Order `json:"order"`
|
||||
}
|
||||
|
||||
type Direct struct {
|
||||
SerialNumber string `json:"serialNumber"`
|
||||
OrderOrderNumber string `json:"orderOrderNumber"`
|
||||
TerminalAccount string `json:"terminalAccount"`
|
||||
OursProductId int `json:"oursProductId"`
|
||||
OursProductName string `json:"oursProductName"`
|
||||
Status int `json:"status"`
|
||||
TradePrice float64 `json:"tradePrice"`
|
||||
PlatformProductId int `json:"platformProductId"`
|
||||
PlatformProductName string `json:"platformProductName"`
|
||||
PlatformId int `json:"platformId"`
|
||||
PlatformName string `json:"platformName"`
|
||||
PlatformPrice float64 `json:"platformPrice"`
|
||||
CreateTime int `json:"createTime"`
|
||||
ExecuteTime int `json:"executeTime"`
|
||||
Type int `json:"type"`
|
||||
Reason string `json:"reason"`
|
||||
ResellerId int `json:"resellerId"`
|
||||
ResellerName string `json:"resellerName"`
|
||||
Aftermarket int `json:"aftermarket"`
|
||||
PurchasePrice float64 `json:"purchasePrice"`
|
||||
NeedAi bool `json:"needAi"`
|
||||
AiReason string `json:"aiReason"`
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
Id string `json:"id"`
|
||||
ResellerId int `json:"resellerId"`
|
||||
ResellerName string `json:"resellerName"`
|
||||
Status int `json:"status"`
|
||||
PayStatus int `json:"payStatus"`
|
||||
CreateTime int `json:"createTime"`
|
||||
PayTime int `json:"payTime"`
|
||||
Type int `json:"type"`
|
||||
Account string `json:"account"`
|
||||
Quantity int `json:"quantity"`
|
||||
Amount float64 `json:"amount"`
|
||||
PayAmount float64 `json:"payAmount"`
|
||||
ResellerOrderNumber string `json:"resellerOrderNumber"`
|
||||
Price int `json:"price"`
|
||||
NotifyTime int `json:"notifyTime"`
|
||||
FinishTime int `json:"finishTime"`
|
||||
Aftermarket int `json:"aftermarket"`
|
||||
Remark string `json:"remark"`
|
||||
OursProductId int `json:"oursProductId"`
|
||||
OursProductName string `json:"oursProductName"`
|
||||
OursProductPrice int `json:"oursProductPrice"`
|
||||
TradePrice float64 `json:"tradePrice"`
|
||||
}
|
||||
type ZltxOrderLogResponse struct {
|
||||
Code int `json:"code"`
|
||||
Error string `json:"error"`
|
||||
|
|
@ -171,12 +233,15 @@ func (w *ZltxOrderDetailTool) getZltxOrderDetail(ctx context.Context, rec *entit
|
|||
if err = json.Unmarshal(res.Content, &resData); err != nil {
|
||||
return
|
||||
}
|
||||
entitys.ResJson(rec.Ch, w.Name(), res.Text)
|
||||
|
||||
if resData.Data.Direct != nil {
|
||||
if rec.OutPutScene == entitys.OutPutSceneDingTalk {
|
||||
entitys.ResJson(rec.Ch, w.Name(), resData.ToForm())
|
||||
} else {
|
||||
entitys.ResJson(rec.Ch, w.Name(), res.Text)
|
||||
entitys.ResLoading(rec.Ch, w.Name(), "正在分析订单日志")
|
||||
}
|
||||
if resData.Data.Direct != nil {
|
||||
req = l_request.Request{
|
||||
Url: fmt.Sprintf(w.config.Tools.ZltxOrderDetail.AddURL, resData.Data.Direct["orderOrderNumber"].(string), resData.Data.Direct["serialNumber"].(string)),
|
||||
Url: fmt.Sprintf(w.config.Tools.ZltxOrderDetail.AddURL, resData.Data.Direct.OrderOrderNumber, resData.Data.Direct.SerialNumber),
|
||||
Headers: map[string]string{
|
||||
"Authorization": fmt.Sprintf("Bearer %s", token),
|
||||
},
|
||||
|
|
@ -230,3 +295,95 @@ func (w *ZltxOrderDetailTool) getZltxOrderDetail(ctx context.Context, rec *entit
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (z *ZltxOrderDetailResponse) ToForm() string {
|
||||
var res strings.Builder
|
||||
res.WriteString("**普通订单** \n")
|
||||
res.WriteString("\n## 订单号:" + z.Data.Order.Id)
|
||||
res.WriteString("\n## 分销商订单号:" + z.Data.Order.ResellerOrderNumber)
|
||||
res.WriteString("\n## 分销商:" + z.Data.Order.ResellerName)
|
||||
res.WriteString("\n## 订单商品:" + z.Data.Order.OursProductName)
|
||||
res.WriteString("\n## 充值账号:" + z.Data.Order.Account)
|
||||
res.WriteString("\n## 折扣价/原价:" + fmt.Sprintf("%.2f", z.Data.Order.TradePrice))
|
||||
res.WriteString("\n## 数量:" + fmt.Sprintf("%d", z.Data.Order.Quantity))
|
||||
res.WriteString("\n## 订单总额:" + fmt.Sprintf("%.2f", z.Data.Order.Amount))
|
||||
res.WriteString("\n## 订单状态:" + orderStatusMap(z.Data.Order.Status))
|
||||
res.WriteString("\n## 支付状态:" + orderPayStatusMap(z.Data.Order.Status))
|
||||
res.WriteString("\n## 创建时间:" + unixToDateFormat(z.Data.Order.CreateTime))
|
||||
res.WriteString("\n## 完成时间:" + unixToDateFormat(z.Data.Order.FinishTime))
|
||||
res.WriteString("\n---\n")
|
||||
|
||||
res.WriteString("\n**充值流水** \n")
|
||||
res.WriteString("\n## 订单号:" + z.Data.Direct.OrderOrderNumber)
|
||||
res.WriteString("\n## 流水号:" + z.Data.Direct.SerialNumber)
|
||||
res.WriteString("\n## 商品:" + z.Data.Direct.OursProductName)
|
||||
res.WriteString("\n## 使用接口:" + z.Data.Direct.PlatformName)
|
||||
res.WriteString("\n## 接口商品名称:" + z.Data.Direct.PlatformProductName)
|
||||
res.WriteString("\n## 上游价:" + fmt.Sprintf("%.2f", z.Data.Direct.PlatformPrice))
|
||||
res.WriteString("\n## 下游价:" + fmt.Sprintf("%.2f", z.Data.Direct.TradePrice))
|
||||
res.WriteString("\n## 上游采购价:" + fmt.Sprintf("%.2f", z.Data.Direct.PurchasePrice))
|
||||
res.WriteString("\n## 充值账号:" + z.Data.Direct.TerminalAccount)
|
||||
res.WriteString("\n## 创建时间:" + unixToDateFormat(z.Data.Direct.CreateTime))
|
||||
res.WriteString("\n## 处理时间:" + unixToDateFormat(z.Data.Direct.ExecuteTime))
|
||||
res.WriteString("\n## 状态:" + directStatusMap(z.Data.Direct.Status))
|
||||
res.WriteString("\n")
|
||||
res.WriteString("\n")
|
||||
res.WriteString("\n")
|
||||
return res.String()
|
||||
}
|
||||
|
||||
func orderStatusMap(status int) string {
|
||||
var OrderStatus = map[int]string{
|
||||
0: "下单中",
|
||||
1: "订单完成",
|
||||
2: "部分成功",
|
||||
3: "充值处理中",
|
||||
4: "已暂停",
|
||||
-1: "关闭订单",
|
||||
-2: "全部失败",
|
||||
}
|
||||
if _, ok := OrderStatus[status]; !ok {
|
||||
return "未知"
|
||||
}
|
||||
return OrderStatus[status]
|
||||
}
|
||||
|
||||
func unixToDateFormat(unix int) string {
|
||||
return time.Unix(int64(unix), 0).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
func orderPayStatusMap(status int) string {
|
||||
var OrderPayStatus = map[int]string{
|
||||
0: "未支付",
|
||||
1: "支付中",
|
||||
2: "支付成功",
|
||||
3: "退款中",
|
||||
4: "全部退款",
|
||||
5: "部分退款",
|
||||
-1: "支付失败",
|
||||
-2: "退款失败",
|
||||
}
|
||||
if _, ok := OrderPayStatus[status]; !ok {
|
||||
return "未知"
|
||||
}
|
||||
return OrderPayStatus[status]
|
||||
}
|
||||
|
||||
func directStatusMap(status int) string {
|
||||
var DirectStatus = map[int]string{
|
||||
0: "待充值",
|
||||
1: "充值成功",
|
||||
2: "充值中",
|
||||
-1: "充值失败",
|
||||
-2: "失败重试",
|
||||
-98: "下单异常",
|
||||
-99: "查询异常",
|
||||
-6: "手动失败",
|
||||
-5: "手动重试",
|
||||
-4: "叠加卡单",
|
||||
-3: "卡单",
|
||||
}
|
||||
if _, ok := DirectStatus[status]; !ok {
|
||||
return "未知"
|
||||
}
|
||||
return DirectStatus[status]
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue