@@ -0,0 +1,38 @@
+package timetask
+
+import (
+ "time"
+)
+func Run() {
+ checkIsExpire()
+ expireRemind()
+}
+//每天0点 检查试用、vip服务是否到期
+func checkIsExpire() {
+ crontab(0, func() {
+ })
+//即将到期或者已到期发推送消息
+func expireRemind() {
+ crontab(10, func() {
+func crontab(hour int, f func()) {
+ go f()
+ now := time.Now()
+ t := time.Date(now.Year(), now.Month(), now.Day()+1, hour, 0, 0, 0, time.Local)
+ timer := time.NewTimer(t.Sub(now))
+ for {
+ select {
+ case <-timer.C:
+ timer.Reset(24 * time.Hour)
+ }