rdluck 4 年之前
父节点
当前提交
956f631d9c
共有 4 个文件被更改,包括 31 次插入2 次删除
  1. 1 1
      models/company_product.go
  2. 12 1
      models/report.go
  3. 7 0
      services/report.go
  4. 11 0
      services/task.go

+ 1 - 1
models/company_product.go

@@ -82,7 +82,7 @@ func GetCompanyOldDataSync() (items []*Company, err error) {
 	sql := `SELECT * FROM company WHERE company_id NOT IN(
 			SELECT company_id FROM company_product
 			)
-			AND company_belong='partner' AND company_id<>1 `
+			AND company_id<>1 `
 	o := orm.NewOrm()
 	_, err = o.Raw(sql).QueryRows(&items)
 	return

+ 12 - 1
models/report.go

@@ -1,6 +1,11 @@
 package models
 
-import "rdluck_tools/orm"
+import (
+	"fmt"
+	"hongze/hongze_task/utils"
+	"rdluck_tools/orm"
+	"time"
+)
 
 type Report struct {
 	Id         int
@@ -39,3 +44,9 @@ func EditReportContent(reportId int, content, contentSub string) (err error) {
 	_, err = o.Raw(sql, content, contentSub, reportId).Exec()
 	return
 }
+
+//删除报告日志记录-保留3个月
+func DeleteReportSaveLog()  {
+	startDateTime:=time.Now().AddDate(0,-3,0).Format(utils.FormatDateTime)
+	fmt.Println(startDateTime)
+}

+ 7 - 0
services/report.go

@@ -112,3 +112,10 @@ func FixReportContentSub() {
 //		}
 //	}
 //}
+
+func DeleteReportSaveLog()(err error) {
+	fmt.Println("start")
+	models.DeleteReportSaveLog()
+	fmt.Println("end")
+	return
+}

+ 11 - 0
services/task.go

@@ -40,6 +40,10 @@ func Task() {
 	companyLoss := toolbox.NewTask("companyLoss", "0 20 0 * * *", CompanyLoss)
 	toolbox.AddTask("companyLoss", companyLoss)
 
+	//删除日志记录
+	deleteReportSaveLog := toolbox.NewTask("deleteReportSaveLog", "0 20 0 * * *", DeleteReportSaveLog)
+	toolbox.AddTask("deleteReportSaveLog", deleteReportSaveLog)
+
 	toolbox.StartTask()
 	//GetHistoryLzProductDetail()
 	//GetLzPrice()
@@ -49,6 +53,13 @@ func Task() {
 	fmt.Println("task end")
 }
 
+func Task123() {
+	fmt.Println("start")
+	//0 42 4 1 * *                         毎月1日的 4:42 分 执行
+	DeleteReportSaveLog()
+	fmt.Println("end")
+}
+
 func SendEmail() (err error) {
 	//报告历史访问次数
 	go ReportViewTimes()