Compare commits

..

No commits in common. "cda8e1fc6e6cdd006d54778d3bb8c4ec8808c9e6" and "21b9501be625a399570c63c6f70e6c60828bdac0" have entirely different histories.

7 changed files with 12 additions and 57 deletions

View File

@ -72,7 +72,7 @@ func (g *GroupConfigBiz) GetReportLists(ctx context.Context, groupConfig *model.
product = strings.Split(groupConfig.ProductName, ",")
}
reportList, err := bbxt.NewBbxtTools(g.conf)
reportList, err := bbxt.NewBbxtTools()
if err != nil {
return
}
@ -145,8 +145,8 @@ func (g *GroupConfigBiz) handleReport(ctx context.Context, rec *entitys.Recogniz
}
}
}
rep, err := bbxt.NewBbxtTools(g.conf)
uploader := bbxt.NewUploader(g.ossClient, g.conf)
rep, err := bbxt.NewBbxtTools()
uploader := bbxt.NewUploader(g.ossClient)
if err != nil {
return err
}

View File

@ -296,25 +296,3 @@ func LoadConfigWithTest() (*Config, error) {
return &bc, nil
}
func LoadConfigWithEnv() (*Config, error) {
var bc Config
modularDir, err := pkg.GetModuleDir()
if err != nil {
return nil, err
}
viper.SetConfigFile(modularDir + "/config/config_env.yaml")
viper.SetConfigType("yaml")
// 读取配置文件
if err := viper.ReadInConfig(); err != nil {
return nil, fmt.Errorf("failed to read config file: %w", err)
}
// 解析配置
if err := viper.Unmarshal(&bc); err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
return &bc, nil
}

View File

@ -9,7 +9,6 @@ import (
"ai_scheduler/internal/domain/workflow/runtime"
"ai_scheduler/internal/pkg/lsxd"
"ai_scheduler/internal/pkg/utils_oss"
"ai_scheduler/pkg"
"ai_scheduler/utils"
"context"
"errors"
@ -159,7 +158,8 @@ func (w *statisticsOursProduct) callStatisticsTool(ctx context.Context, state *S
func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, state *StatisticsOursProductContext) (*StatisticsOursProductContext, error) {
// 1. 获取模板路径
cwd, _ := pkg.GetModuleDir()
// cwd, _ := filepath.Abs("../../") // 单元测试用
cwd, _ := filepath.Abs(".")
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))

View File

@ -50,8 +50,7 @@ var (
// run 函数是程序的入口函数,负责初始化和配置各个组件
func run() {
// 加载测试配置
// configConfig, err = config.LoadConfigWithTest()
configConfig, err = config.LoadConfigWithEnv()
configConfig, err = config.LoadConfigWithTest()
// 初始化数据库连接
db, _ := utils.NewGormDb(configConfig)
// 初始化各种实现层组件

View File

@ -1,7 +1,6 @@
package bbxt
import (
"ai_scheduler/internal/config"
pkginner "ai_scheduler/internal/pkg"
"ai_scheduler/internal/pkg/utils_oss"
"ai_scheduler/pkg"
@ -42,10 +41,9 @@ type BbxtTools struct {
cacheDir string
excelTempDir string
ossClient *utils_oss.Client
config *config.Config
}
func NewBbxtTools(config *config.Config) (*BbxtTools, error) {
func NewBbxtTools() (*BbxtTools, error) {
cache, err := pkg.GetCacheDir()
if err != nil {
return nil, err
@ -58,7 +56,6 @@ func NewBbxtTools(config *config.Config) (*BbxtTools, error) {
return &BbxtTools{
cacheDir: cache,
excelTempDir: fmt.Sprintf("%s/excel_temp", tempDir),
config: config,
}, nil
}
@ -84,7 +81,7 @@ func (b *BbxtTools) DailyReport(now time.Time, downWardValue int32, productName
reports = append(reports, profitRankingSum, statisOfficialProductSum, statisOfficialProductSumDecline)
if ossClient != nil {
uploader := NewUploader(ossClient, b.config)
uploader := NewUploader(ossClient)
for _, report := range reports {
_ = uploader.Run(report)
}

View File

@ -1,7 +1,6 @@
package bbxt
import (
"ai_scheduler/internal/config"
"ai_scheduler/internal/pkg/utils_oss"
"bytes"
"fmt"
@ -20,13 +19,13 @@ import (
type Uploader struct {
ossClient *utils_oss.Client
config *config.Config
}
func NewUploader(oss *utils_oss.Client, config *config.Config) *Uploader {
const RequestUrl = "http://excel2pic:8000/api/v1/convert"
func NewUploader(oss *utils_oss.Client) *Uploader {
return &Uploader{
ossClient: oss,
config: config,
}
}
@ -119,7 +118,7 @@ func (u *Uploader) excel2picPy(templatePath string, excelBytes []byte, scale int
// 3. 发送 HTTP POST 请求
req, err := http.NewRequest("POST", u.config.EinoTools.Excel2Pic.BaseURL, body)
req, err := http.NewRequest("POST", RequestUrl, body)
if err != nil {
return nil, fmt.Errorf("create request failed: %v", err)
}

View File

@ -69,12 +69,6 @@ type OrderAfterSaleSupplierData struct {
SaleType int `json:"saleType"` // 处理方式 1.加款 2.扣款
ExecuteTime int `json:"executeTime"` // 流水创建时间
IsExistsAfterSale bool `json:"isExistsAfterSale"` // 是否已存在售后
ResellerID int `json:"resellerId"` // 分销商id
ResellerName string `json:"resellerName"` // 分销商名称
Aftermarket int `json:"aftermarket"` // 透传即可
OrderType int `json:"orderType"` // 透传即可
OrderNumber string `json:"orderNumber"` // 透传即可
SettleType int `json:"settleType"` // 透传即可
}
// 接口返回
@ -99,12 +93,6 @@ type OrderAfterSaleSupplierApiBase struct {
PlatformID int `json:"platformId"` // 上游平台id
SignCompanyName string `json:"signCompanyName"` // 签约主体名称
ExecuteTime int `json:"executeTime"` // 充值执行时间
ResellerID int `json:"resellerId"` // 分销商id
ResellerName string `json:"resellerName"` // 分销商名称
Aftermarket int `json:"aftermarket"` // 透传即可
OrderType int `json:"orderType"` // 透传即可
OrderNumber string `json:"orderNumber"` // 透传即可
SettleType int `json:"settleType"` // 透传即可
}
type OrderAfterSaleSupplierApiExtItem struct {
IsExistsAfterSale bool `json:"existAfterSales"` // 是否已存在售后 - 未使用
@ -282,12 +270,6 @@ func (t *OrderAfterSaleSupplierTool) getAfterSaleSupplierList(headers map[string
Reason: originInput.AfterSalesReason,
SalePrice: afterSalesPrice,
SaleType: afterType,
ResellerID: item.ResellerID,
ResellerName: item.ResellerName,
Aftermarket: item.Aftermarket,
OrderType: item.OrderType,
OrderNumber: item.OrderNumber,
SettleType: item.SettleType,
})
}