fix: 优化登录配置和API调用
This commit is contained in:
parent
aa3151baa5
commit
5831eefd4f
|
|
@ -21,19 +21,27 @@ vllm:
|
||||||
|
|
||||||
coze:
|
coze:
|
||||||
base_url: "https://api.coze.cn"
|
base_url: "https://api.coze.cn"
|
||||||
api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
|
||||||
|
|
||||||
|
redis:
|
||||||
|
host: 47.97.27.195:6379
|
||||||
|
type: node
|
||||||
|
pass:
|
||||||
|
lansexiongdi@666i_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
||||||
|
|
||||||
|
lsxd:
|
||||||
|
# 统一登录
|
||||||
|
login_url: "http://api.test.user.1688sup.com/v1/login/phone"
|
||||||
|
phone: "0zmINhJBwsDJYTmeaxXK4A=="
|
||||||
|
password: "LSSGoWhc63NpZc1rq3LT8g=="
|
||||||
|
check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome"
|
||||||
|
|
||||||
|
|
||||||
sys:
|
sys:
|
||||||
session_len: 6
|
session_len: 6
|
||||||
channel_pool_len: 100
|
channel_pool_len: 100
|
||||||
channel_pool_size: 32
|
channel_pool_size: 32
|
||||||
llm_pool_len: 5
|
llm_pool_len: 5
|
||||||
heartbeat_interval: 30
|
heartbeat_interval: 30
|
||||||
redis:
|
|
||||||
host: 47.97.27.195:6379
|
|
||||||
type: node
|
|
||||||
pass: lansexiongdi@666
|
|
||||||
key: report-api
|
key: report-api
|
||||||
pollSize: 5 #连接池大小,不配置,或配置为0表示不启用连接池
|
pollSize: 5 #连接池大小,不配置,或配置为0表示不启用连接池
|
||||||
minIdleConns: 2 #最小空闲连接数
|
minIdleConns: 2 #最小空闲连接数
|
||||||
|
|
@ -128,7 +136,7 @@ eino_tools:
|
||||||
# 我们的商品统计
|
# 我们的商品统计
|
||||||
rechargeStatisticsOursProduct:
|
rechargeStatisticsOursProduct:
|
||||||
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
||||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MTc5ODgzLCJuYmYiOjE3NjcxNjkwODMsImp0aSI6IjEiLCJQaG9uZSI6IjE4MjAwMTYwMTQzIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MiwiR3JvdXBDb2RlcyI6IkxTWEREU19TWVNURU0sU1RBVElTVElDQUxTWVNURU1fQURNSU4sUEhZU0lDQUxHT09EU19BRE1JTiIsIkRpbmdVc2VySWQiOiIifQ.ELNF1Iv6yEwA12nCbXGKwXCw-F5Gq4GI2t2nqo1PlSkFdQ5Oz5s5NwV0RUXA66LxCggI-9IjBtFI1MvBHpvTHq9QRlm-HKzVTMcOBkEtKEfCCI6SPKVTAZyntTJlWPKG3u-CJUotT5YW0j2rU1VcpA7uGEiY7gs5VPUOZ80R1uGJ7HBSqVI2DRqar6STa1xryygdCjK7qamUM2d6aJ6r9VPTBt-JO6dkDdw3KHs3wl-PGM3wcbXHZ2aC18WFd_PxLmtjqErpxTEkdUBCnUHOSKDePG0henDJq71Nh3yRdRmY9VvszHMyIxJA2BVGPIPUT_Y5aewaaEMQVEjhiBnn-Q"
|
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,6 @@ eino_tools:
|
||||||
# 我们的商品统计
|
# 我们的商品统计
|
||||||
rechargeStatisticsOursProduct:
|
rechargeStatisticsOursProduct:
|
||||||
base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct"
|
base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct"
|
||||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MDc3NzcwLCJuYmYiOjE3NjcwNzU5NzAsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.Nuw_aR6iSPmhhh9E5rhyTxHBsgWtaTZvbnc7SFTnUBJXTQvYahnk0LyZaVpsVw6FB3cU0F5xOdX3rmGyWyaiszWO6yi-o1oxGMXwhf39fMiWT2xUI6pAn9Ync8DmZ4tOMCNUTdEk4CaQFzrTwJs0c-VR4yW6LgoPmNPvUVZ-KwmusUpnPz5j9RsJItzIWE3bpGGsfB54e2UERcZdbo9BXxCZIBbpAYKBKdl73KuI8SNaXgKvGTrJ6hEN4ESpnbisJVwT5pp_kuChJlcfjHTHFsEf4RJDjN9gTrtDbBWZyY3OmO2ukqYAM7tZPs6TXJwvQGJQsFRVZUBGxS1nD_6DzQ"
|
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,13 @@ coze:
|
||||||
api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
api_secret: "sat_AqvFcdNgesP8megy1ItTscWFXRcsHRzmM4NJ1KNavfcdT0EPwYuCPkDqGhItpx13"
|
||||||
|
|
||||||
|
|
||||||
|
lsxd:
|
||||||
|
# 统一登录
|
||||||
|
login_url: "http://api.test.user.1688sup.com/v1/login/phone"
|
||||||
|
phone: "0zmINhJBwsDJYTmeaxXK4A=="
|
||||||
|
password: "LSSGoWhc63NpZc1rq3LT8g=="
|
||||||
|
check_token_url: "http://api.test.user.1688sup.com/v1/user/welcome"
|
||||||
|
|
||||||
sys:
|
sys:
|
||||||
session_len: 6
|
session_len: 6
|
||||||
channel_pool_len: 100
|
channel_pool_len: 100
|
||||||
|
|
@ -127,8 +134,7 @@ eino_tools:
|
||||||
# == 电商充值系统 ==
|
# == 电商充值系统 ==
|
||||||
# 我们的商品统计
|
# 我们的商品统计
|
||||||
rechargeStatisticsOursProduct:
|
rechargeStatisticsOursProduct:
|
||||||
base_url: "http://admin.lanseds.cn/admin/statistics/oursProduct"
|
base_url: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct"
|
||||||
api_key: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MTc5ODgzLCJuYmYiOjE3NjcxNjkwODMsImp0aSI6IjEiLCJQaG9uZSI6IjE4MjAwMTYwMTQzIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MiwiR3JvdXBDb2RlcyI6IkxTWEREU19TWVNURU0sU1RBVElTVElDQUxTWVNURU1fQURNSU4sUEhZU0lDQUxHT09EU19BRE1JTiIsIkRpbmdVc2VySWQiOiIifQ.ELNF1Iv6yEwA12nCbXGKwXCw-F5Gq4GI2t2nqo1PlSkFdQ5Oz5s5NwV0RUXA66LxCggI-9IjBtFI1MvBHpvTHq9QRlm-HKzVTMcOBkEtKEfCCI6SPKVTAZyntTJlWPKG3u-CJUotT5YW0j2rU1VcpA7uGEiY7gs5VPUOZ80R1uGJ7HBSqVI2DRqar6STa1xryygdCjK7qamUM2d6aJ6r9VPTBt-JO6dkDdw3KHs3wl-PGM3wcbXHZ2aC18WFd_PxLmtjqErpxTEkdUBCnUHOSKDePG0henDJq71Nh3yRdRmY9VvszHMyIxJA2BVGPIPUT_Y5aewaaEMQVEjhiBnn-Q"
|
|
||||||
excel2pic:
|
excel2pic:
|
||||||
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
base_url: "http://192.168.6.109:8010/api/v1/convert"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -633,27 +633,28 @@ 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) {
|
||||||
|
|
||||||
reportList, err := bbxt.NewBbxtTools()
|
//var product []string
|
||||||
if err != nil {
|
//if group.ProductName != "" {
|
||||||
return
|
// product = strings.Split(group.ProductName, ",")
|
||||||
}
|
//}
|
||||||
var product []string
|
|
||||||
if group.ProductName != "" {
|
//reportList, err := bbxt.NewBbxtTools()
|
||||||
product = strings.Split(group.ProductName, ",")
|
//if err != nil {
|
||||||
}
|
// return
|
||||||
//[]string{"官方-爱奇艺-星钻季卡", "官方-爱奇艺-星钻半年卡", "官方--腾讯-年卡", "官方--爱奇艺-月卡"}
|
//}
|
||||||
reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient)
|
|
||||||
if err != nil {
|
//reports, err = reportList.DailyReport(time.Now(), bbxt.DownWardValue, product, bbxt.SumFilter, d.ossClient)
|
||||||
|
//if err != nil {
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
//product = []string{"优酷周卡", "优酷季卡", "优酷年卡", "爱奇艺黄金会员天卡"}
|
||||||
|
//追加电商充值系统统计 - 返回统一使用[]*bbxt.ReportRes
|
||||||
|
rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), nil, d.ossClient)
|
||||||
|
if err != nil || len(rechargeReports) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 追加电商充值系统统计 - 返回统一使用 []*bbxt.ReportRes
|
reports = append(reports, rechargeReports...)
|
||||||
//rechargeReports, err := d.rechargeDailyReport(ctx, time.Now(), product, d.ossClient)
|
|
||||||
//if err != nil || len(rechargeReports) == 0 {
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//reports = append(reports, rechargeReports...)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,21 @@ import (
|
||||||
"ai_scheduler/internal/config"
|
"ai_scheduler/internal/config"
|
||||||
"ai_scheduler/internal/data/impl"
|
"ai_scheduler/internal/data/impl"
|
||||||
"ai_scheduler/internal/pkg/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
|
"ai_scheduler/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Repos 聚合所有 Repository
|
// Repos 聚合所有 Repository
|
||||||
type Repos struct {
|
type Repos struct {
|
||||||
Session SessionRepo
|
Session SessionRepo
|
||||||
OssClient *utils_oss.Client
|
OssClient *utils_oss.Client
|
||||||
|
Rdb *utils.Rdb
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRepos(sessionImpl *impl.SessionImpl, cfg *config.Config) *Repos {
|
func NewRepos(sessionImpl *impl.SessionImpl, cfg *config.Config, rdb *utils.Rdb) *Repos {
|
||||||
ossClient, _ := utils_oss.NewClient(cfg)
|
ossClient, _ := utils_oss.NewClient(cfg)
|
||||||
return &Repos{
|
return &Repos{
|
||||||
Session: NewSessionAdapter(sessionImpl),
|
Session: NewSessionAdapter(sessionImpl),
|
||||||
OssClient: ossClient,
|
OssClient: ossClient,
|
||||||
|
Rdb: rdb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ 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"
|
||||||
|
|
@ -14,14 +16,16 @@ 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,
|
cfg: cfg, // 将传入的配置参数赋值给 Client 结构体的 cfg 字段
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call 调用我们的商品统计接口
|
// Call 调用我们的商品统计接口
|
||||||
func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest) ([]StatisticsOursProductItem, error) {
|
func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest, rdb *utils.Rdb, lsxdcfg *config.LSXDConfig) ([]StatisticsOursProductItem, error) {
|
||||||
// 构建 URL 参数
|
// 构建 URL 参数
|
||||||
var queryParams []string
|
var queryParams []string
|
||||||
|
|
||||||
|
|
@ -44,9 +48,9 @@ func (c *Client) Call(ctx context.Context, req StatisticsOursProductRequest) ([]
|
||||||
|
|
||||||
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", c.cfg.APIKey),
|
"Authorization": fmt.Sprintf("Bearer %s", token),
|
||||||
}
|
}
|
||||||
|
|
||||||
reqObj := l_request.Request{
|
reqObj := l_request.Request{
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,33 @@ 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) {
|
||||||
cfg := config.ToolConfig{
|
rdb := utils.NewRdb(&config.Config{
|
||||||
BaseURL: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct",
|
Redis: config.Redis{
|
||||||
APIKey: "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ1c2VyQ2VudGVyIiwiZXhwIjoxNzY3MDc3NzcwLCJuYmYiOjE3NjcwNzU5NzAsImp0aSI6IjEiLCJQaG9uZSI6IjE4MDAwMDAwMDAwIiwiVXNlck5hbWUiOiJsc3hkIiwiUmVhbE5hbWUiOiLotoXnuqfnrqHnkIblkZgiLCJBY2NvdW50VHlwZSI6MSwiR3JvdXBDb2RlcyI6IlZDTF9DQVNISUVSLFZDTF9PUEVSQVRFLFZDTF9BRE1JTixWQ0xfQUFBLFZDTF9WQ0xfT1BFUkFULFZDTF9JTlZPSUNFLENSTV9BRE1JTixMSUFOTElBTl9BRE1JTixNQVJLRVRNQUcyX0FETUlOLFBIT05FQklMTF9BRE1JTixRSUFOWkhVX1NVUFBFUl9BRE0sTUFSS0VUSU5HU0FBU19TVVBFUkFETUlOLENBUkRfQ09ERSxDQVJEX1BST0NVUkVNRU5ULE1BUktFVElOR1NZU1RFTV9TVVBFUixTVEFUSVNUSUNBTFNZU1RFTV9BRE1JTixaTFRYX0FETUlOLFpMVFhfT1BFUkFURSIsIkRpbmdVc2VySWQiOiIxNjIwMjYxMjMwMjg5MzM4MzQifQ.Nuw_aR6iSPmhhh9E5rhyTxHBsgWtaTZvbnc7SFTnUBJXTQvYahnk0LyZaVpsVw6FB3cU0F5xOdX3rmGyWyaiszWO6yi-o1oxGMXwhf39fMiWT2xUI6pAn9Ync8DmZ4tOMCNUTdEk4CaQFzrTwJs0c-VR4yW6LgoPmNPvUVZ-KwmusUpnPz5j9RsJItzIWE3bpGGsfB54e2UERcZdbo9BXxCZIBbpAYKBKdl73KuI8SNaXgKvGTrJ6hEN4ESpnbisJVwT5pp_kuChJlcfjHTHFsEf4RJDjN9gTrtDbBWZyY3OmO2ukqYAM7tZPs6TXJwvQGJQsFRVZUBGxS1nD_6DzQ",
|
Host: "47.97.27.195:6379",
|
||||||
|
Pass: "lansexiongdi@666",
|
||||||
|
Key: "report-api-test",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
configEino := config.ToolConfig{
|
||||||
|
BaseURL: "http://admin.1688sup.cn:8001/admin/statistics/oursProduct",
|
||||||
|
APIKey: "OFJ8UpqOlI7+w3Qklf36ZA==",
|
||||||
|
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(cfg)
|
client := New(configEino)
|
||||||
|
|
||||||
req := StatisticsOursProductRequest{
|
req := StatisticsOursProductRequest{
|
||||||
Page: 1,
|
Page: 1,
|
||||||
|
|
@ -24,7 +40,7 @@ func TestClient_Call(t *testing.T) {
|
||||||
|
|
||||||
// 由于没有真实的后端环境和 Token,这里注释掉实际调用
|
// 由于没有真实的后端环境和 Token,这里注释掉实际调用
|
||||||
// 在开发环境中,你可以取消注释并填入有效的 Token 进行测试
|
// 在开发环境中,你可以取消注释并填入有效的 Token 进行测试
|
||||||
res, err := client.Call(context.Background(), req)
|
res, err := client.Call(context.Background(), req, rdb, configLSXD)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf("Call failed: %v", err)
|
t.Logf("Call failed: %v", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"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/utils_oss"
|
"ai_scheduler/internal/pkg/utils_oss"
|
||||||
|
"ai_scheduler/utils"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
@ -24,7 +25,7 @@ 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}, nil
|
return &statisticsOursProduct{cfg: d.Conf, toolManager: d.ToolManager, ossClient: d.Repos.OssClient, rdb: d.Repos.Rdb}, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,6 +33,7 @@ type statisticsOursProduct struct {
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
toolManager *toolManager.Manager
|
toolManager *toolManager.Manager
|
||||||
ossClient *utils_oss.Client
|
ossClient *utils_oss.Client
|
||||||
|
rdb *utils.Rdb
|
||||||
}
|
}
|
||||||
|
|
||||||
type StatisticsOursProductWorkflowInput struct {
|
type StatisticsOursProductWorkflowInput struct {
|
||||||
|
|
@ -103,7 +105,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"
|
||||||
endTime := input.Time.Format("2006010215")
|
endTime := input.Time.Format("2006010215")
|
||||||
endTimeStr := input.Time.Format("1.2号15点")
|
endTimeStr := input.Time.Format("1.2号15点")
|
||||||
|
|
||||||
|
|
@ -122,7 +125,7 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *S
|
||||||
Serial: []string{state.StartTime, state.EndTime},
|
Serial: []string{state.StartTime, state.EndTime},
|
||||||
}
|
}
|
||||||
|
|
||||||
dataList, err := w.toolManager.Recharge.StatisticsOursProduct.Call(ctx, req)
|
dataList, err := w.toolManager.Recharge.StatisticsOursProduct.Call(ctx, req, w.rdb, &w.cfg.LSXD)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("调用统计我们的商品工具失败: %v", err)
|
log.Errorf("调用统计我们的商品工具失败: %v", err)
|
||||||
return nil, fmt.Errorf("获取统计我们的商品数据失败")
|
return nil, fmt.Errorf("获取统计我们的商品数据失败")
|
||||||
|
|
@ -138,7 +141,7 @@ 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("../../")
|
||||||
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))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Login struct {
|
type Login struct {
|
||||||
config *config.Config
|
config *config.LSXDConfig
|
||||||
redisCli *redis.Client
|
redisCli *redis.Client
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLogin(config *config.Config, rdb *utils.Rdb) *Login {
|
func NewLogin(config *config.LSXDConfig, rdb *utils.Rdb) *Login {
|
||||||
return &Login{
|
return &Login{
|
||||||
config: config,
|
config: config,
|
||||||
redisCli: rdb.Rdb,
|
redisCli: rdb.Rdb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *Login) GetToken() 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 {
|
||||||
|
|
@ -74,7 +72,7 @@ func (l *Login) GetToken() 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.LSXD.CheckTokenURL
|
checkTokenURL := l.config.CheckTokenURL
|
||||||
if checkTokenURL == "" {
|
if checkTokenURL == "" {
|
||||||
return token != ""
|
return token != ""
|
||||||
}
|
}
|
||||||
|
|
@ -96,9 +94,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.LSXD.LoginURL
|
loginURL := l.config.LoginURL
|
||||||
phone := l.config.LSXD.Phone
|
phone := l.config.Phone
|
||||||
password := l.config.LSXD.Password
|
password := l.config.Password
|
||||||
|
|
||||||
// 2.调用登录接口获取token
|
// 2.调用登录接口获取token
|
||||||
if loginURL == "" {
|
if loginURL == "" {
|
||||||
|
|
@ -111,7 +109,7 @@ func (l *Login) login(ctx context.Context) (string, error) {
|
||||||
reqBody := map[string]any{
|
reqBody := map[string]any{
|
||||||
"phone": phone,
|
"phone": phone,
|
||||||
"password": password,
|
"password": password,
|
||||||
"code": "123456",
|
"code": "456789",
|
||||||
}
|
}
|
||||||
bodyBytes, err := json.Marshal(reqBody)
|
bodyBytes, err := json.Marshal(reqBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package lsxd
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/config"
|
"ai_scheduler/internal/config"
|
||||||
"ai_scheduler/utils"
|
"ai_scheduler/utils"
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -16,15 +17,13 @@ func TestGetToken(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
login := NewLogin(&config.Config{
|
login := NewLogin(&config.LSXDConfig{
|
||||||
LSXD: config.LSXDConfig{
|
LoginURL: "http://api.test.user.1688sup.com/v1/login/phone",
|
||||||
LoginURL: "http://api.test.user.1688sup.com/v1/login/phone",
|
Phone: "OFJ8UpqOlI7+w3Qklf36ZA==",
|
||||||
Phone: "0zmINhJBwsDJYTmeaxXK4A==",
|
Password: "tEbFegH/DRRh6LutFb7o3g==",
|
||||||
Password: "LSSGoWhc63NpZc1rq3LT8g==",
|
CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome",
|
||||||
CheckTokenURL: "http://api.test.user.1688sup.com/v1/user/welcome",
|
|
||||||
},
|
|
||||||
}, rdb)
|
}, rdb)
|
||||||
token := login.GetToken()
|
token := login.GetToken(context.Background())
|
||||||
if token == "" {
|
if token == "" {
|
||||||
t.Errorf("token is empty")
|
t.Errorf("token is empty")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,13 +66,13 @@ func (c *CronServer) Run(ctx context.Context) {
|
||||||
}
|
}
|
||||||
c.log.Infof("任务[%d]:%s执行结束", jobID, job.Name)
|
c.log.Infof("任务[%d]:%s执行结束", jobID, job.Name)
|
||||||
}()
|
}()
|
||||||
|
c.log.Infof("任务[%d]:%s执ddd", jobID, job.Name)
|
||||||
// 为每次执行创建新的上下文
|
// 为每次执行创建新的上下文
|
||||||
ctx := context.Background()
|
//ctx := context.Background()
|
||||||
err := job.Func(ctx)
|
//err := job.Func(ctx)
|
||||||
if err != nil {
|
//if err != nil {
|
||||||
c.log.Errorf("任务[%d]:%s执行失败: %s", jobID, job.Name, err.Error())
|
// c.log.Errorf("任务[%d]:%s执行失败: %s", jobID, job.Name, err.Error())
|
||||||
}
|
//}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.log.Errorf("添加任务失败:%s", err.Error())
|
c.log.Errorf("添加任务失败:%s", err.Error())
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,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 := 29
|
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
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ func run() {
|
||||||
// 初始化Redis数据库连接
|
// 初始化Redis数据库连接
|
||||||
rdb := utils.NewRdb(configConfig)
|
rdb := utils.NewRdb(configConfig)
|
||||||
// 初始化仓库层
|
// 初始化仓库层
|
||||||
repos := repo.NewRepos(sessionImpl, configConfig)
|
repos := repo.NewRepos(sessionImpl, configConfig, rdb)
|
||||||
// 初始化包级别的Redis连接
|
// 初始化包级别的Redis连接
|
||||||
pkgRdb := pkg.NewRdb(configConfig)
|
pkgRdb := pkg.NewRdb(configConfig)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue