sms_job.go 475B

12345678910111213141516171819202122232425
  1. package jobcron
  2. import (
  3. "SCRM/service/sms_service"
  4. "SCRM/utils"
  5. "github.com/robfig/cron"
  6. )
  7. // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
  8. var smsCronJob *cron.Cron
  9. func init() {
  10. smsCronJob = cron.New()
  11. spec := "0 */5 * * * ?" // 每五分钟检查一次
  12. smsCronJob.AddFunc(spec, func() {
  13. utils.TraceLog("定时发送未发送的短信")
  14. sms_service.SMSSendUnsendBatchRealTime()
  15. })
  16. }
  17. func BeginSendUnsendSMSCronJob() {
  18. smsCronJob.Start()
  19. }