Merge remote-tracking branch 'origin/v4' into v4

This commit is contained in:
renzhiyuan 2025-12-31 18:29:07 +08:00
commit 08c2094940
2 changed files with 24 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import (
"fmt"
"math/rand"
"path/filepath"
"strconv"
"time"
"github.com/cloudwego/eino/compose"
@ -179,6 +180,29 @@ func (w *statisticsOursProduct) generateExcelAndUpload(ctx context.Context, stat
func (w *statisticsOursProduct) convertDataToExcelFormat(data []statistics_ours_product.StatisticsOursProductItem) [][]string {
var result [][]string
for _, item := range data {
var profitVal float64
// 处理 Profit 字段类型
switch v := item.Profit.(type) {
case float64:
profitVal = v
case string:
if val, err := strconv.ParseFloat(v, 64); err == nil {
profitVal = val
} else {
// 解析失败默认为0或者记录错误
profitVal = 0
}
default:
// 其他类型视为0
profitVal = 0
}
// 过滤利润小于 -100 的记录
if profitVal < -100 {
continue
}
row := []string{
item.OursProductName,
// fmt.Sprintf("%d", item.OursProductId),