Sfoglia il codice sorgente

crontab clear update orders

abiao 5 anni fa
parent
commit
fc9fe3dc3d

+ 4 - 0
go/gopath/src/fohow.com/apps/controllers/cron_controller/init.go

@@ -1,6 +1,7 @@
 package cron_controller
 
 import (
+	"fohow.com/apps/models/express_model"
 	"github.com/astaxie/beego"
 	"github.com/astaxie/beego/context"
 
@@ -81,6 +82,9 @@ func exec(name string) {
 		go OrderCancelAutomatically()
 	case "send_cent": //补发积分执行一次
 		go patchCent()
+	case "clear_update_orders": //清理过期物流数据
+		go patchCent()
+		go express_model.ClearUpdateOrders()
 	default:
 		beego.BeeLogger.Error("Didn't get task wity name:[%s]", name)
 	}

+ 14 - 0
go/gopath/src/fohow.com/apps/models/express_model/express_company.go

@@ -60,3 +60,17 @@ func GetCompanyByNo(expressNo string, useCache bool) *ExpressCompany {
 	}
 	return item
 }
+
+//冗余订单物流清理
+func ClearUpdateOrders() {
+	nowTime := time.Now()
+	getTime := nowTime.AddDate(0, -1, 0)             //年,月,日   获取一个月前的时间
+	resTime := getTime.Format("2006-01-02 15:04:05") //获取的时间的格式
+	o := orm.NewOrm()
+	sql := `
+		delete from update_orders where created_at<=?
+	`
+	o.Raw(sql, resTime).Exec()
+
+	return
+}