orderNotice定时任务
This commit is contained in:
parent
0700044a0e
commit
8a64a2b32e
|
|
@ -8,6 +8,24 @@ import (
|
|||
|
||||
func (s *VoucherService) CronNotice(ctx context.Context) error {
|
||||
|
||||
c, ok := s.bc.Cron.CommandMap["orderNotice"]
|
||||
|
||||
if !ok {
|
||||
log.Warn("orderNotice定时任务未开启")
|
||||
return nil
|
||||
}
|
||||
|
||||
return s.cron.AddFunc(c.Command, func() {
|
||||
|
||||
if err := s.Notice(ctx); err != nil {
|
||||
log.Errorf("orderNotice定时任务执行发生错误: %v", err)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
func (s *VoucherService) Notice(ctx context.Context) error {
|
||||
start := time.Now()
|
||||
|
||||
if err := s.VoucherBiz.Notice(ctx); err != nil {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package service
|
||||
|
||||
import (
|
||||
"github.com/robfig/cron"
|
||||
"voucher/internal/biz"
|
||||
"voucher/internal/biz/mixrepos"
|
||||
"voucher/internal/biz/wechatrepo"
|
||||
|
|
@ -9,6 +10,7 @@ import (
|
|||
|
||||
type VoucherService struct {
|
||||
bc *conf.Bootstrap
|
||||
cron *cron.Cron
|
||||
VoucherBiz *biz.VoucherBiz
|
||||
CmbMixRepo mixrepos.CmbMixRepo
|
||||
WechatCpnRepo wechatrepo.WechatCpnRepo
|
||||
|
|
@ -16,12 +18,14 @@ type VoucherService struct {
|
|||
|
||||
func NewVoucherService(
|
||||
bc *conf.Bootstrap,
|
||||
cron *cron.Cron,
|
||||
VoucherBiz *biz.VoucherBiz,
|
||||
CmbMixRepo mixrepos.CmbMixRepo,
|
||||
WechatCpnRepo wechatrepo.WechatCpnRepo,
|
||||
) *VoucherService {
|
||||
return &VoucherService{
|
||||
bc: bc,
|
||||
cron: cron,
|
||||
VoucherBiz: VoucherBiz,
|
||||
CmbMixRepo: CmbMixRepo,
|
||||
WechatCpnRepo: WechatCpnRepo,
|
||||
|
|
|
|||
Loading…
Reference in New Issue