|
@@ -3,53 +3,116 @@ package timetask
|
|
|
import (
|
|
|
"context"
|
|
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2"
|
|
|
- "github.com/gogf/gf/v2/frame/g"
|
|
|
+ "github.com/gogf/gf/v2/os/gcfg"
|
|
|
"github.com/gogf/gf/v2/os/gcron"
|
|
|
"github.com/gogf/gf/v2/os/gctx"
|
|
|
"telemarketingEtl/entity"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func TimeTask() {
|
|
|
- //TaskEventInfo()
|
|
|
- //TaskSearchInfo()
|
|
|
- TaskVisitInfo()
|
|
|
- return
|
|
|
- var (
|
|
|
- err error
|
|
|
- ctx = gctx.New()
|
|
|
- )
|
|
|
- _, err = gcron.Add(ctx, "1 0 0 * * *", func(ctx context.Context) {
|
|
|
- g.Log().Print(ctx, "Every day")
|
|
|
- //Task_clearUserLog()
|
|
|
- }, "clearUserTask")
|
|
|
- if err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+//func TimeTask() {
|
|
|
+// //TaskEventInfo()
|
|
|
+// //TaskSearchInfo()
|
|
|
+// TaskVisitInfo()
|
|
|
+// return
|
|
|
+// var (
|
|
|
+// err error
|
|
|
+// ctx = gctx.New()
|
|
|
+// )
|
|
|
+// _, err = gcron.Add(ctx, "1 0 0 * * *", func(ctx context.Context) {
|
|
|
+// g.Log().Print(ctx, "Every day")
|
|
|
+// //Task_clearUserLog()
|
|
|
+// }, "clearUserTask")
|
|
|
+// if err != nil {
|
|
|
+// panic(err)
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|
|
|
|
|
|
func TaskEventInfo() {
|
|
|
now := time.Now()
|
|
|
end := now.Unix()
|
|
|
- //start := now.Add(-time.Hour * 24).Unix()
|
|
|
- entity.EventInfoAdd(1677657397, end)
|
|
|
+ start := now.Add(-time.Hour * 24).Unix()
|
|
|
+ //查看事件
|
|
|
+ entity.EventInfoAdd(start, end)
|
|
|
}
|
|
|
|
|
|
func TaskSearchInfo() {
|
|
|
now := time.Now()
|
|
|
end := now.Unix()
|
|
|
- //start := now.Add(-time.Hour * 24).Unix()
|
|
|
- entity.SearchInfoAdd(1677657397, end)
|
|
|
+ start := now.Add(-time.Hour * 24).Unix()
|
|
|
+ //搜索事件
|
|
|
+ entity.SearchInfoAdd(start, end)
|
|
|
}
|
|
|
|
|
|
func TaskVisitInfo() {
|
|
|
now := time.Now()
|
|
|
end := now.Unix()
|
|
|
- //start := now.Add(-time.Hour * 24).Unix()
|
|
|
- entity.VisitInfoAdd(1677657397, end)
|
|
|
+ start := now.Add(-time.Hour * 24).Unix()
|
|
|
+ entity.VisitInfoAdd(start, end)
|
|
|
}
|
|
|
|
|
|
func TaskOpenSea() {
|
|
|
entity.GetOpenSea()
|
|
|
}
|
|
|
+
|
|
|
+// 定时任务
|
|
|
+func Run() {
|
|
|
+ timetaskBl := gcfg.Instance().MustGet(gctx.New(), "timetaskBl", "").Bool()
|
|
|
+ if timetaskBl {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ ctx = gctx.New()
|
|
|
+ )
|
|
|
+
|
|
|
+ eventInfoTask := gcfg.Instance().MustGet(gctx.New(), "eventInfoTask", "").String()
|
|
|
+ searchInfoTask := gcfg.Instance().MustGet(gctx.New(), "searchInfoTask", "").String()
|
|
|
+ visitInfoTask := gcfg.Instance().MustGet(gctx.New(), "visitInfoTask", "").String()
|
|
|
+ openSeaTask := gcfg.Instance().MustGet(gctx.New(), "openSeaTask", "").String()
|
|
|
+ deleteOpenSeaTask := gcfg.Instance().MustGet(gctx.New(), "deleteOpenSeaTask", "").String()
|
|
|
+ returnOpenSeaTask := gcfg.Instance().MustGet(gctx.New(), "returnOpenSeaTask", "").String()
|
|
|
+ //
|
|
|
+ _, err = gcron.Add(ctx, eventInfoTask, func(ctx context.Context) {
|
|
|
+ TaskEventInfo()
|
|
|
+ }, "TaskEventInfo")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ //
|
|
|
+ _, err = gcron.Add(ctx, searchInfoTask, func(ctx context.Context) {
|
|
|
+ TaskSearchInfo()
|
|
|
+ }, "TaskSearchInfo")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ //
|
|
|
+ _, err = gcron.Add(ctx, visitInfoTask, func(ctx context.Context) {
|
|
|
+ TaskVisitInfo()
|
|
|
+ }, "TaskVisitInfo")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ //
|
|
|
+ _, err = gcron.Add(ctx, openSeaTask, func(ctx context.Context) {
|
|
|
+ TaskOpenSea()
|
|
|
+ }, "TaskOpenSea")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ //
|
|
|
+ _, err = gcron.Add(ctx, deleteOpenSeaTask, func(ctx context.Context) {
|
|
|
+ entity.DeleteOpenSea()
|
|
|
+ }, "DeleteOpenSea")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ //
|
|
|
+ _, err = gcron.Add(ctx, returnOpenSeaTask, func(ctx context.Context) {
|
|
|
+ entity.ReturnOpenSea()
|
|
|
+ }, "ReturnOpenSea")
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|