ai_scheduler/internal/services/cron.go

45 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package services
import (
"ai_scheduler/internal/biz"
"ai_scheduler/internal/config"
"context"
"github.com/gofiber/fiber/v2/log"
)
type CronService struct {
config *config.Config
dingTalkBotBiz *biz.DingTalkBotBiz
}
func NewCronService(config *config.Config, dingTalkBotBiz *biz.DingTalkBotBiz) *CronService {
return &CronService{
config: config,
dingTalkBotBiz: dingTalkBotBiz,
}
}
func (d *CronService) CronReportSend(ctx context.Context) error {
groupId := 29
groupInfo, err := d.dingTalkBotBiz.GetGroupInfo(ctx, groupId)
if err != nil {
return err
}
reports, err := d.dingTalkBotBiz.GetReportLists(ctx, &groupInfo)
if err != nil {
return err
}
//contentChan <- "截止今日23点利润亏损合计127917.0866元亏损500元以上的分销商和产品金额如下图"
//contentChan <- "![图片](https://lsxdmgoss.oss-cn-chengdu.aliyuncs.com/MarketingSaaS/image/V2/other/shanghu.png)"
for _, report := range reports {
err = d.dingTalkBotBiz.SendReport(ctx, &groupInfo, report)
if err != nil {
log.Error(err)
continue
}
}
return nil
}