fix: 添加负利润分析清理功能
This commit is contained in:
parent
6d31c923fb
commit
3b8af9ada9
|
|
@ -48,12 +48,31 @@ func (m *Macro) Router(ctx context.Context, reqContent string, groupConfig *mode
|
||||||
return m.NegativeProfitGet(ctx)
|
return m.NegativeProfitGet(ctx)
|
||||||
case strings.HasPrefix(reqContent, "[负利润分析]更新"):
|
case strings.HasPrefix(reqContent, "[负利润分析]更新"):
|
||||||
return m.NegativeProfitUpdate(ctx, reqContent, groupConfig)
|
return m.NegativeProfitUpdate(ctx, reqContent, groupConfig)
|
||||||
|
case strings.HasPrefix(reqContent, "[负利润分析]清理"):
|
||||||
|
return m.NegativeProfitClear(ctx, reqContent, groupConfig)
|
||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Macro) NegativeProfitClear(ctx context.Context, content string, groupConfig *model.AiBotGroupConfig) (successMsg string, err error, isFinish bool) {
|
||||||
|
dayDate := time.Now().Format(time.DateOnly)
|
||||||
|
cond := builder.NewCond()
|
||||||
|
cond = cond.And(builder.Eq{"cache_index": bbxt.IndexLossSumDetail})
|
||||||
|
cond = cond.And(builder.Eq{"cache_key": dayDate})
|
||||||
|
err = m.reportDailyCacheImpl.UpdateByCond(&cond, &model.AiReportDailyCache{
|
||||||
|
Status: 2,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("解析失败:%v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
isFinish = true
|
||||||
|
successMsg = "清理成功"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Macro) NegativeProfitUpdate(ctx context.Context, content string, groupConfig *model.AiBotGroupConfig) (successMsg string, err error, isFinish bool) {
|
func (m *Macro) NegativeProfitUpdate(ctx context.Context, content string, groupConfig *model.AiBotGroupConfig) (successMsg string, err error, isFinish bool) {
|
||||||
//newContent := strings.ReplaceAll(strings.TrimSpace(content), "[负利润分析]更新:", "")
|
//newContent := strings.ReplaceAll(strings.TrimSpace(content), "[负利润分析]更新:", "")
|
||||||
jsonData, err := ParseLossData(content)
|
jsonData, err := ParseLossData(content)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ type AiReportDailyCache struct {
|
||||||
CacheKey string `gorm:"column:cache_key;not null;default:1;comment:索引方式,可以是任意类型" json:"cache_key"` // 索引方式,可以是任意类型
|
CacheKey string `gorm:"column:cache_key;not null;default:1;comment:索引方式,可以是任意类型" json:"cache_key"` // 索引方式,可以是任意类型
|
||||||
Value string `gorm:"column:value;comment:类型下所需路由以及参数" json:"value"` // 类型下所需路由以及参数
|
Value string `gorm:"column:value;comment:类型下所需路由以及参数" json:"value"` // 类型下所需路由以及参数
|
||||||
CacheIndex string `gorm:"column:cache_index;not null;comment:类型" json:"cache_index"` // 类型
|
CacheIndex string `gorm:"column:cache_index;not null;comment:类型" json:"cache_index"` // 类型
|
||||||
|
Status int32 `gorm:"column:status;not null;default:1" json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName AiReportDailyCache's table name
|
// TableName AiReportDailyCache's table name
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue