diff --git a/configs/config.yaml b/configs/config.yaml index c505118..fc40b93 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -83,7 +83,7 @@ cron: commandMap: orderNotice: isOpen: false #是否启动 true/false - command: "0 1 * * *" # 每天凌晨1点执行一次:0 2 * * * | "0 */10 * * *" #cron表达式,每10分钟执行一次 + command: "0 0 1 * * ?" # 每天凌晨1点执行一次 #配置日志 logs: diff --git a/configs/config_test.yaml b/configs/config_test.yaml index 1b1960b..dfbf049 100644 --- a/configs/config_test.yaml +++ b/configs/config_test.yaml @@ -80,7 +80,7 @@ cron: commandMap: orderNotice: isOpen: true #是否启动 true/false - command: "0 1 * * *" # 每天凌晨1点执行一次:0 2 * * * | "0 */10 * * *" #cron表达式,每10分钟执行一次 + command: "0 0 1 * * ?" # 每天凌晨1点执行一次 #配置日志 logs: diff --git a/internal/service/consume.go b/internal/service/consume.go index a2cd14c..17c7420 100644 --- a/internal/service/consume.go +++ b/internal/service/consume.go @@ -29,7 +29,7 @@ func (j *VoucherService) GetNotifyRetryConfig() *mq.ConsumerConfig { func (j *VoucherService) NotifyRetryConsumer(ctx context.Context, msg *mq.ConsumerMessage) error { shardingKey := msg.GetShardingKey() - if shardingKey == "" { + if len(shardingKey) == 0 { log.Error("notify retry 消费异常,获取 shardingKey 失败") return errors.New("orderNotify 消费异常,获取 orderNo 失败") } diff --git a/internal/service/cron.go b/internal/service/cron.go index febef44..add07ce 100644 --- a/internal/service/cron.go +++ b/internal/service/cron.go @@ -25,6 +25,13 @@ func (s *VoucherService) CronOrderNotice(ctx context.Context) error { return nil } + // 每五秒: */5 * * * * ? + // 每隔1分钟执行一次:"0 */1 * * * ?" + // 每天23点执行一次:"0 0 23 * * ?" + // 每天凌晨1点执行一次:"0 0 1 * * ?" + // 每月1号凌晨1点执行一次:"0 0 1 1 * ?" + // 在26分、29分、33分执行一次:"0 26,29,33 * * * ?" + // 每天的0点、13点、18点、21点都执行一次:"0 0 0,13,18,21 * * ?" return s.cron.AddFunc(c.Command, func() { s.OrderNotice(ctx)