voucher/internal/service/voucher.go

48 lines
1.1 KiB
Go

package service
import (
"context"
"github.com/go-kratos/kratos/v2/log"
"time"
"voucher/internal/biz"
"voucher/internal/biz/mixrepos"
"voucher/internal/biz/wechatrepo"
"voucher/internal/conf"
)
type VoucherService struct {
bc *conf.Bootstrap
VoucherBiz *biz.VoucherBiz
CmbMixRepo mixrepos.CmbMixRepo
WechatCpnRepo wechatrepo.WechatCpnRepo
}
func NewVoucherService(
bc *conf.Bootstrap,
VoucherBiz *biz.VoucherBiz,
CmbMixRepo mixrepos.CmbMixRepo,
WechatCpnRepo wechatrepo.WechatCpnRepo,
) *VoucherService {
return &VoucherService{
bc: bc,
VoucherBiz: VoucherBiz,
CmbMixRepo: CmbMixRepo,
WechatCpnRepo: WechatCpnRepo,
}
}
func (s *VoucherService) OrderNotice(ctx context.Context) error {
start := time.Now()
if err := s.VoucherBiz.OrderNotice(ctx); err != nil {
log.Error("订单定时通知,执行失败,err: %v", err)
}
end := time.Now()
elapsed := end.Sub(start)
log.Warnf("订单定时通知,开始执行时间%s,执行结束时间%s,代码块执行耗时: %s", start.Format(time.DateTime), end.Format(time.DateTime), elapsed)
return nil
}