fix: 电商充值系统我们的商品统计调整
This commit is contained in:
parent
5831eefd4f
commit
0eea75cd6c
|
|
@ -30,10 +30,10 @@ coze:
|
||||||
|
|
||||||
lsxd:
|
lsxd:
|
||||||
# 统一登录
|
# 统一登录
|
||||||
login_url: "http://api.test.user.1688sup.com/v1/login/phone"
|
login_url: "https://api.user.1688sup.com/v1/login/phone"
|
||||||
phone: "0zmINhJBwsDJYTmeaxXK4A=="
|
phone: "ORlviZN7N06W2+WKLe76xg=="
|
||||||
password: "LSSGoWhc63NpZc1rq3LT8g=="
|
password: "V5Uh8C4bamEM6UQZh4TCeQ=="
|
||||||
check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome"
|
check_token_url: "https://api.user.1688sup.com/v1/user/welcome"
|
||||||
|
|
||||||
|
|
||||||
sys:
|
sys:
|
||||||
|
|
@ -136,7 +136,8 @@ eino_tools:
|
||||||
# 我们的商品统计
|
# 我们的商品统计
|
||||||
rechargeStatisticsOursProduct:
|
rechargeStatisticsOursProduct:
|
||||||
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||||
|
# == 通用工具 ==
|
||||||
|
# 表格转图片
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
|
|
@ -147,6 +148,9 @@ dingtalk:
|
||||||
url: "https://alidocs.dingtalk.com/i/nodes/2Amq4vjg89RnYx9DTp66m2orW3kdP0wQ"
|
url: "https://alidocs.dingtalk.com/i/nodes/2Amq4vjg89RnYx9DTp66m2orW3kdP0wQ"
|
||||||
base_id: "2Amq4vjg89RnYx9DTp66m2orW3kdP0wQ"
|
base_id: "2Amq4vjg89RnYx9DTp66m2orW3kdP0wQ"
|
||||||
sheet_id_or_name: "数据表"
|
sheet_id_or_name: "数据表"
|
||||||
|
# 机器人群组
|
||||||
|
bot_group_id:
|
||||||
|
bbxt: 28
|
||||||
|
|
||||||
default_prompt:
|
default_prompt:
|
||||||
img_recognize:
|
img_recognize:
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ coze:
|
||||||
|
|
||||||
lsxd:
|
lsxd:
|
||||||
# 统一登录
|
# 统一登录
|
||||||
login_url: "http://api.test.user.1688sup.com/v1/login/phone"
|
login_url: "https://api.user.1688sup.com/v1/login/phone"
|
||||||
phone: "0zmINhJBwsDJYTmeaxXK4A=="
|
phone: "ORlviZN7N06W2+WKLe76xg=="
|
||||||
password: "LSSGoWhc63NpZc1rq3LT8g=="
|
password: "V5Uh8C4bamEM6UQZh4TCeQ=="
|
||||||
check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome"
|
check_token_url: "https://api.user.1688sup.com/v1/user/welcome"
|
||||||
|
|
||||||
|
|
||||||
sys:
|
sys:
|
||||||
|
|
@ -131,7 +131,9 @@ eino_tools:
|
||||||
# == 电商充值系统 ==
|
# == 电商充值系统 ==
|
||||||
# 我们的商品统计
|
# 我们的商品统计
|
||||||
rechargeStatisticsOursProduct:
|
rechargeStatisticsOursProduct:
|
||||||
base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct"
|
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||||
|
# == 通用工具 ==
|
||||||
|
# 表格转图片
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
|
|
@ -142,6 +144,9 @@ dingtalk:
|
||||||
url: "https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
url: "https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||||
base_id: "YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
base_id: "YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||||
sheet_id_or_name: "数据表"
|
sheet_id_or_name: "数据表"
|
||||||
|
# 机器人群组
|
||||||
|
bot_group_id:
|
||||||
|
bbxt: 23
|
||||||
|
|
||||||
|
|
||||||
default_prompt:
|
default_prompt:
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,10 @@ coze:
|
||||||
|
|
||||||
lsxd:
|
lsxd:
|
||||||
# 统一登录
|
# 统一登录
|
||||||
login_url: "http://api.test.user.1688sup.com/v1/login/phone"
|
login_url: "https://api.user.1688sup.com/v1/login/phone"
|
||||||
phone: "0zmINhJBwsDJYTmeaxXK4A=="
|
phone: "ORlviZN7N06W2+WKLe76xg=="
|
||||||
password: "LSSGoWhc63NpZc1rq3LT8g=="
|
password: "V5Uh8C4bamEM6UQZh4TCeQ=="
|
||||||
check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome"
|
check_token_url: "https://api.user.1688sup.com/v1/user/welcome"
|
||||||
|
|
||||||
sys:
|
sys:
|
||||||
session_len: 6
|
session_len: 6
|
||||||
|
|
@ -134,7 +134,9 @@ eino_tools:
|
||||||
# == 电商充值系统 ==
|
# == 电商充值系统 ==
|
||||||
# 我们的商品统计
|
# 我们的商品统计
|
||||||
rechargeStatisticsOursProduct:
|
rechargeStatisticsOursProduct:
|
||||||
base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct"
|
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||||
|
# == 通用工具 ==
|
||||||
|
# 表格转图片
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
|
|
@ -145,6 +147,9 @@ dingtalk:
|
||||||
url: "https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
url: "https://alidocs.dingtalk.com/i/nodes/YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||||
base_id: "YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
base_id: "YQBnd5ExVE6qAbnOiANQg2KKJyeZqMmz"
|
||||||
sheet_id_or_name: "数据表"
|
sheet_id_or_name: "数据表"
|
||||||
|
# 机器人群组
|
||||||
|
bot_group_id:
|
||||||
|
bbxt: 23
|
||||||
|
|
||||||
default_prompt:
|
default_prompt:
|
||||||
img_recognize:
|
img_recognize:
|
||||||
|
|
|
||||||
|
|
@ -633,20 +633,20 @@ func (d *DingTalkBotBiz) HandleStreamRes(ctx context.Context, data *chatbot.BotC
|
||||||
|
|
||||||
func (d *DingTalkBotBiz) GetReportLists(ctx context.Context, group *model.AiBotGroup) (reports []*bbxt.ReportRes, err error) {
|
func (d *DingTalkBotBiz) GetReportLists(ctx context.Context, group *model.AiBotGroup) (reports []*bbxt.ReportRes, err error) {
|
||||||
|
|
||||||
//var product []string
|
var product []string
|
||||||
//if group.ProductName != "" {
|
if group.ProductName != "" {
|
||||||
// product = strings.Split(group.ProductName, ",")
|
product = strings.Split(group.ProductName, ",")
|
||||||
//}
|
}
|
||||||
|
|
||||||
//reportList, err := bbxt.NewBbxtTools()
|
reportList, err := bbxt.NewBbxtTools()
|
||||||
//if err != nil {
|
if err != nil {
|
||||||
// return
|
return
|
||||||
//}
|
}
|
||||||
|
|
||||||
//reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient)
|
reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient)
|
||||||
//if err != nil {
|
if err != nil {
|
||||||
// return
|
return
|
||||||
//}
|
}
|
||||||
//product = []string{"优酷周卡", "优酷季卡", "优酷年卡", "爱奇艺黄金会员天卡"}
|
//product = []string{"优酷周卡", "优酷季卡", "优酷年卡", "爱奇艺黄金会员天卡"}
|
||||||
//追加电商充值系统统计 - 返回统一使用[]*bbxt.ReportRes
|
//追加电商充值系统统计 - 返回统一使用[]*bbxt.ReportRes
|
||||||
rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), nil, d.ossClient)
|
rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), nil, d.ossClient)
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ type DingtalkConfig struct {
|
||||||
ApiKey string `mapstructure:"api_key"`
|
ApiKey string `mapstructure:"api_key"`
|
||||||
ApiSecret string `mapstructure:"api_secret"`
|
ApiSecret string `mapstructure:"api_secret"`
|
||||||
TableDemand AITableConfig `mapstructure:"table_demand"`
|
TableDemand AITableConfig `mapstructure:"table_demand"`
|
||||||
|
BotGroupID map[string]int `mapstructure:"bot_group_id"` // 机器人群组
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableDemandConfig 需求表配置
|
// TableDemandConfig 需求表配置
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,17 @@ package component
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/domain/component/callback"
|
"ai_scheduler/internal/domain/component/callback"
|
||||||
|
"ai_scheduler/internal/pkg/lsxd"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Components struct {
|
type Components struct {
|
||||||
Callback callback.Manager
|
Callback callback.Manager
|
||||||
|
LSXDLogin *lsxd.Login
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewComponents(callbackManager callback.Manager) *Components {
|
func NewComponents(callbackManager callback.Manager, lsxdLogin *lsxd.Login) *Components {
|
||||||
return &Components{
|
return &Components{
|
||||||
Callback: callbackManager,
|
Callback: callbackManager,
|
||||||
|
LSXDLogin: lsxdLogin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ package statistics_ours_product
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/config"
|
"ai_scheduler/internal/config"
|
||||||
"ai_scheduler/internal/pkg/l_request"
|
"ai_scheduler/internal/pkg/l_request"
|
||||||
"ai_scheduler/internal/pkg/lsxd"
|
|
||||||
"ai_scheduler/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -16,16 +14,14 @@ type Client struct {
|
||||||
cfg config.ToolConfig
|
cfg config.ToolConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// New 是一个客户端构造函数,接收一个 config.ToolConfig 类型的配置参数
|
|
||||||
// 返回一个初始化后的 Client 指针
|
|
||||||
func New(cfg config.ToolConfig) *Client {
|
func New(cfg config.ToolConfig) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
cfg: cfg, // 将传入的配置参数赋值给 Client 结构体的 cfg 字段
|
cfg: cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call 调用我们的商品统计接口
|
// Call 调用我们的商品统计接口
|
||||||
func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest, rdb *utils.Rdb, lsxdcfg *config.LSXDConfig) ([]StatisticsOursProductItem, error) {
|
func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest) ([]StatisticsOursProductItem, error) {
|
||||||
// 构建 URL 参数
|
// 构建 URL 参数
|
||||||
var queryParams []string
|
var queryParams []string
|
||||||
|
|
||||||
|
|
@ -48,9 +44,8 @@ func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest, rdb
|
||||||
|
|
||||||
queryString := strings.Join(queryParams, "&")
|
queryString := strings.Join(queryParams, "&")
|
||||||
fullURL := fmt.Sprintf("%s?%s", c.cfg.BaseURL, queryString)
|
fullURL := fmt.Sprintf("%s?%s", c.cfg.BaseURL, queryString)
|
||||||
token := lsxd.NewLogin(lsxdcfg, rdb).GetToken(ctx)
|
|
||||||
headers := map[string]string{
|
headers := map[string]string{
|
||||||
"Authorization": fmt.Sprintf("Bearer %s", token),
|
"Authorization": fmt.Sprintf("Bearer %s", req.Token),
|
||||||
}
|
}
|
||||||
|
|
||||||
reqObj := l_request.Request{
|
reqObj := l_request.Request{
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,17 @@ package statistics_ours_product
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/config"
|
"ai_scheduler/internal/config"
|
||||||
"ai_scheduler/utils"
|
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestClient_Call(t *testing.T) {
|
func TestClient_Call(t *testing.T) {
|
||||||
rdb := utils.NewRdb(&config.Config{
|
|
||||||
Redis: config.Redis{
|
|
||||||
Host: "47.97.27.195:6379",
|
|
||||||
Pass: "lansexiongdi@666",
|
|
||||||
Key: "report-api-test",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
configEino := config.ToolConfig{
|
configEino := config.ToolConfig{
|
||||||
BaseURL: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct",
|
BaseURL: "http://admin.lanseds.cn/admin/statistics/oursProduct",
|
||||||
APIKey: "OFJ8UpqOlI7+w3Qklf36ZA==",
|
APIKey: "OFJ8UpqOlI7+w3Qklf36ZA==",
|
||||||
APISecret: "tEbFegH/DRRh6LutFb7o3g==",
|
APISecret: "tEbFegH/DRRh6LutFb7o3g==",
|
||||||
}
|
}
|
||||||
configLSXD := &config.LSXDConfig{
|
|
||||||
LoginURL: "http://api.test.user.1688sup.com/v1/login/phone",
|
|
||||||
Phone: "0zmINhJBwsDJYTmeaxXK4A==",
|
|
||||||
Password: "LSSGoWhc63NpZc1rq3LT8g==",
|
|
||||||
CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome",
|
|
||||||
}
|
|
||||||
|
|
||||||
client := New(configEino)
|
client := New(configEino)
|
||||||
|
|
||||||
|
|
@ -40,7 +26,7 @@ func TestClient_Call(t *testing.T) {
|
||||||
|
|
||||||
// 由于没有真实的后端环境和 Token,这里注释掉实际调用
|
// 由于没有真实的后端环境和 Token,这里注释掉实际调用
|
||||||
// 在开发环境中,你可以取消注释并填入有效的 Token 进行测试
|
// 在开发环境中,你可以取消注释并填入有效的 Token 进行测试
|
||||||
res, err := client.Call(context.Background(), req, rdb, configLSXD)
|
res, err := client.Call(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("Call failed: %v", err)
|
t.Logf("Call failed: %v", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package statistics_ours_product
|
||||||
|
|
||||||
// StatisticsOursProductRequest 我们的商品统计请求参数
|
// StatisticsOursProductRequest 我们的商品统计请求参数
|
||||||
type StatisticsOursProductRequest struct {
|
type StatisticsOursProductRequest struct {
|
||||||
|
Token string `json:"token"` // 登录token
|
||||||
Page int `json:"page"` // 页码
|
Page int `json:"page"` // 页码
|
||||||
Limit int `json:"limit"` // 每页条数
|
Limit int `json:"limit"` // 每页条数
|
||||||
Serial []string `json:"serial"` // 流水号范围 (通常是日期格式,如 YYYYMMDDHH)
|
Serial []string `json:"serial"` // 流水号范围 (通常是日期格式,如 YYYYMMDDHH)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"ai_scheduler/internal/domain/tools/common/excel_generator"
|
"ai_scheduler/internal/domain/tools/common/excel_generator"
|
||||||
"ai_scheduler/internal/domain/tools/recharge/statistics_ours_product"
|
"ai_scheduler/internal/domain/tools/recharge/statistics_ours_product"
|
||||||
"ai_scheduler/internal/domain/workflow/runtime"
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
|
"ai_scheduler/internal/pkg/lsxd"
|
||||||
"ai_scheduler/internal/pkg/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
"ai_scheduler/utils"
|
"ai_scheduler/utils"
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -25,7 +26,13 @@ const WorkflowIDStatisticsOursProduct = "recharge.statisticsOursProduct"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.Register(WorkflowIDStatisticsOursProduct, func(d *runtime.Deps) (runtime.Workflow, error) {
|
runtime.Register(WorkflowIDStatisticsOursProduct, func(d *runtime.Deps) (runtime.Workflow, error) {
|
||||||
return &statisticsOursProduct{cfg: d.Conf, toolManager: d.ToolManager, ossClient: d.Repos.OssClient, rdb: d.Repos.Rdb}, nil
|
return &statisticsOursProduct{
|
||||||
|
cfg: d.Conf,
|
||||||
|
toolManager: d.ToolManager,
|
||||||
|
ossClient: d.Repos.OssClient,
|
||||||
|
rdb: d.Repos.Rdb,
|
||||||
|
lsxdLogin: d.Component.LSXDLogin,
|
||||||
|
}, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,6 +41,7 @@ type statisticsOursProduct struct {
|
||||||
toolManager *toolManager.Manager
|
toolManager *toolManager.Manager
|
||||||
ossClient *utils_oss.Client
|
ossClient *utils_oss.Client
|
||||||
rdb *utils.Rdb
|
rdb *utils.Rdb
|
||||||
|
lsxdLogin *lsxd.Login
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatisticsOursProductWorkflowInput struct {
|
type StatisticsOursProductWorkflowInput struct {
|
||||||
|
|
@ -105,8 +113,8 @@ func (w *statisticsOursProduct) buildWorkflow(ctx context.Context) (compose.Runn
|
||||||
|
|
||||||
// formatContext 整理上下文参数
|
// formatContext 整理上下文参数
|
||||||
func (w *statisticsOursProduct) formatContext(ctx context.Context, input *StatisticsOursProductWorkflowInput) (*StatisticsOursProductContext, error) {
|
func (w *statisticsOursProduct) formatContext(ctx context.Context, input *StatisticsOursProductWorkflowInput) (*StatisticsOursProductContext, error) {
|
||||||
//startTime := input.Time.Format("2006010200")
|
startTime := input.Time.Format("2006010200")
|
||||||
startTime := "2025010500"
|
// startTime := "2025010500"
|
||||||
endTime := input.Time.Format("2006010215")
|
endTime := input.Time.Format("2006010215")
|
||||||
endTimeStr := input.Time.Format("1.2号15点")
|
endTimeStr := input.Time.Format("1.2号15点")
|
||||||
|
|
||||||
|
|
@ -119,13 +127,20 @@ func (w *statisticsOursProduct) formatContext(ctx context.Context, input *Statis
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
|
func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
|
||||||
|
// 前置获取登录token
|
||||||
|
token := w.lsxdLogin.GetToken(ctx)
|
||||||
|
if token == "" {
|
||||||
|
return nil, fmt.Errorf("登录token为空")
|
||||||
|
}
|
||||||
|
|
||||||
req := statistics_ours_product.StatisticsOursProductRequest{
|
req := statistics_ours_product.StatisticsOursProductRequest{
|
||||||
|
Token: token,
|
||||||
Page: 1,
|
Page: 1,
|
||||||
Limit: 100, // 仅取前100条
|
Limit: 100, // 仅取前100条
|
||||||
Serial: []string{state.StartTime, state.EndTime},
|
Serial: []string{state.StartTime, state.EndTime},
|
||||||
}
|
}
|
||||||
|
|
||||||
dataList, err := w.toolManager.Recharge.StatisticsOursProduct.Call(ctx, req, w.rdb, &w.cfg.LSXD)
|
dataList, err := w.toolManager.Recharge.StatisticsOursProduct.Call(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("调用统计我们的商品工具失败: %v", err)
|
log.Errorf("调用统计我们的商品工具失败: %v", err)
|
||||||
return nil, fmt.Errorf("获取统计我们的商品数据失败")
|
return nil, fmt.Errorf("获取统计我们的商品数据失败")
|
||||||
|
|
@ -141,7 +156,8 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *S
|
||||||
|
|
||||||
func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
|
func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
|
||||||
// 1. 获取模板路径
|
// 1. 获取模板路径
|
||||||
cwd, _ := filepath.Abs("../../")
|
// cwd, _ := filepath.Abs("../../") // 单元测试用
|
||||||
|
cwd, _ := filepath.Abs(".")
|
||||||
templatePath := filepath.Join(cwd, "tmpl", "excel_temp", "recharge_statistics_ours_product.xlsx")
|
templatePath := filepath.Join(cwd, "tmpl", "excel_temp", "recharge_statistics_ours_product.xlsx")
|
||||||
fileName := fmt.Sprintf("statistics_ours_product_%d%d", time.Now().Unix(), rand.Intn(1000))
|
fileName := fmt.Sprintf("statistics_ours_product_%d%d", time.Now().Unix(), rand.Intn(1000))
|
||||||
|
|
||||||
|
|
@ -152,7 +168,7 @@ func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, stat
|
||||||
req := &excel_generator.ExcelGeneratorRequest{
|
req := &excel_generator.ExcelGeneratorRequest{
|
||||||
TemplatePath: templatePath,
|
TemplatePath: templatePath,
|
||||||
ExcelData: excelData,
|
ExcelData: excelData,
|
||||||
StartRow: 4,
|
StartRow: 3,
|
||||||
StyleRow: 3,
|
StyleRow: 3,
|
||||||
Title: state.Title,
|
Title: state.Title,
|
||||||
}
|
}
|
||||||
|
|
@ -193,16 +209,18 @@ func (w *statisticsOursProduct) convertDataToExcelFormat(data []statistics_ours_
|
||||||
if val, err := strconv.ParseFloat(v, 64); err == nil {
|
if val, err := strconv.ParseFloat(v, 64); err == nil {
|
||||||
profitVal = val
|
profitVal = val
|
||||||
} else {
|
} else {
|
||||||
// 解析失败默认为0,或者记录错误
|
// 解析失败默认为0,或者记录错误日志
|
||||||
|
log.Errorf("解析 Profit 字段失败: %v", v)
|
||||||
profitVal = 0
|
profitVal = 0
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// 其他类型视为0
|
// 其他类型视为0,或者记录错误日志
|
||||||
|
log.Errorf("未知 Profit 类型: %T", v)
|
||||||
profitVal = 0
|
profitVal = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过滤利润小于 -100 的记录
|
// 过滤利润小于 -100 的记录
|
||||||
if profitVal < -100 {
|
if profitVal > -100 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Login struct {
|
type Login struct {
|
||||||
config *config.LSXDConfig
|
config *config.Config
|
||||||
redisCli *redis.Client
|
redisCli *redis.Client
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLogin(config *config.LSXDConfig, rdb *utils.Rdb) *Login {
|
func NewLogin(config *config.Config, rdb *utils.Rdb) *Login {
|
||||||
return &Login{
|
return &Login{
|
||||||
config: config,
|
config: config,
|
||||||
redisCli: rdb.Rdb,
|
redisCli: rdb.Rdb,
|
||||||
|
|
@ -32,6 +32,8 @@ func NewLogin(config *config.LSXDConfig, rdb *utils.Rdb) *Login {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Login) GetToken(ctx context.Context) string {
|
func (l *Login) GetToken(ctx context.Context) string {
|
||||||
|
// ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||||
|
// defer cancel()
|
||||||
|
|
||||||
token, err := l.getCachedToken(ctx)
|
token, err := l.getCachedToken(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -72,7 +74,7 @@ func (l *Login) GetToken(ctx context.Context) string {
|
||||||
// 校验token是否有效
|
// 校验token是否有效
|
||||||
func (l *Login) checkTokenValid(ctx context.Context, token string) bool {
|
func (l *Login) checkTokenValid(ctx context.Context, token string) bool {
|
||||||
// 欢迎页校验token有效
|
// 欢迎页校验token有效
|
||||||
checkTokenURL := l.config.CheckTokenURL
|
checkTokenURL := l.config.LSXD.CheckTokenURL
|
||||||
if checkTokenURL == "" {
|
if checkTokenURL == "" {
|
||||||
return token != ""
|
return token != ""
|
||||||
}
|
}
|
||||||
|
|
@ -94,9 +96,9 @@ func (l *Login) checkTokenValid(ctx context.Context, token string) bool {
|
||||||
// 调用登录接口获取token
|
// 调用登录接口获取token
|
||||||
func (l *Login) login(ctx context.Context) (string, error) {
|
func (l *Login) login(ctx context.Context) (string, error) {
|
||||||
// 1.获取配置
|
// 1.获取配置
|
||||||
loginURL := l.config.LoginURL
|
loginURL := l.config.LSXD.LoginURL
|
||||||
phone := l.config.Phone
|
phone := l.config.LSXD.Phone
|
||||||
password := l.config.Password
|
password := l.config.LSXD.Password
|
||||||
|
|
||||||
// 2.调用登录接口获取token
|
// 2.调用登录接口获取token
|
||||||
if loginURL == "" {
|
if loginURL == "" {
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,13 @@ func TestGetToken(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
login := NewLogin(&config.LSXDConfig{
|
login := NewLogin(&config.Config{
|
||||||
LoginURL: "http://api.test.user.1688sup.com/v1/login/phone",
|
LSXD: config.LSXDConfig{
|
||||||
Phone: "OFJ8UpqOlI7+w3Qklf36ZA==",
|
LoginURL: "https://api.user.1688sup.com/v1/login/phone",
|
||||||
Password: "tEbFegH/DRRh6LutFb7o3g==",
|
Phone: "ORlviZN7N06W2+WKLe76xg==",
|
||||||
CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome",
|
Password: "V5Uh8C4bamEM6UQZh4TCeQ==",
|
||||||
|
CheckTokenURL: "https://api.user.1688sup.com/v1/user/welcome",
|
||||||
|
},
|
||||||
}, rdb)
|
}, rdb)
|
||||||
token := login.GetToken(context.Background())
|
token := login.GetToken(context.Background())
|
||||||
if token == "" {
|
if token == "" {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/pkg/dingtalk"
|
"ai_scheduler/internal/pkg/dingtalk"
|
||||||
|
"ai_scheduler/internal/pkg/lsxd"
|
||||||
"ai_scheduler/internal/pkg/utils_langchain"
|
"ai_scheduler/internal/pkg/utils_langchain"
|
||||||
"ai_scheduler/internal/pkg/utils_ollama"
|
"ai_scheduler/internal/pkg/utils_ollama"
|
||||||
"ai_scheduler/internal/pkg/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
|
|
@ -22,4 +23,5 @@ var ProviderSetClient = wire.NewSet(
|
||||||
dingtalk.NewNotableClient,
|
dingtalk.NewNotableClient,
|
||||||
|
|
||||||
utils_oss.NewClient,
|
utils_oss.NewClient,
|
||||||
|
lsxd.NewLogin,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ func NewCronService(config *config.Config, dingTalkBotBiz *biz.DingTalkBotBiz) *
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *CronService) CronReportSend(ctx context.Context) error {
|
func (d *CronService) CronReportSend(ctx context.Context) error {
|
||||||
|
groupId := d.config.Dingtalk.BotGroupID["bbxt"]
|
||||||
groupId := 28
|
|
||||||
groupInfo, err := d.dingTalkBotBiz.GetGroupInfo(ctx, groupId)
|
groupInfo, err := d.dingTalkBotBiz.GetGroupInfo(ctx, groupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"ai_scheduler/internal/domain/workflow/runtime"
|
"ai_scheduler/internal/domain/workflow/runtime"
|
||||||
"ai_scheduler/internal/pkg"
|
"ai_scheduler/internal/pkg"
|
||||||
"ai_scheduler/internal/pkg/dingtalk"
|
"ai_scheduler/internal/pkg/dingtalk"
|
||||||
|
"ai_scheduler/internal/pkg/lsxd"
|
||||||
"ai_scheduler/internal/pkg/utils_ollama"
|
"ai_scheduler/internal/pkg/utils_ollama"
|
||||||
"ai_scheduler/internal/pkg/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
"ai_scheduler/internal/pkg/utils_vllm"
|
"ai_scheduler/internal/pkg/utils_vllm"
|
||||||
|
|
@ -73,8 +74,10 @@ func run() {
|
||||||
botDeptImpl := impl.NewBotDeptImpl(db)
|
botDeptImpl := impl.NewBotDeptImpl(db)
|
||||||
// 初始化Redis管理器
|
// 初始化Redis管理器
|
||||||
redisManager := callback.NewRedisManager(pkgRdb)
|
redisManager := callback.NewRedisManager(pkgRdb)
|
||||||
|
// 初始化登录组件
|
||||||
|
lsxdLogin := lsxd.NewLogin(configConfig, rdb)
|
||||||
// 初始化组件
|
// 初始化组件
|
||||||
components := component.NewComponents(redisManager)
|
components := component.NewComponents(redisManager, lsxdLogin)
|
||||||
// 初始化工作流注册表
|
// 初始化工作流注册表
|
||||||
registry := workflow.NewRegistry(configConfig, client, repos, components)
|
registry := workflow.NewRegistry(configConfig, client, repos, components)
|
||||||
// 初始化钉钉旧版客户端
|
// 初始化钉钉旧版客户端
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue