package svc import ( "applet/app/db" "applet/app/utils" "applet/app/utils/cache" "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tpdaren" "fmt" "strings" "time" ) func GetRunTime(uid, pvdTimeKey, memo string) int64 { sysCfgDb := db.MasterListCfgDb{} sysCfgDb.Set() // 获得最后时间 latest, err := sysCfgDb.MasterListCfgGetOne(uid, pvdTimeKey) if err != nil || latest == nil { sysCfgDb.MasterListCfgInsert(uid, pvdTimeKey, time.Now().String(), memo) latest, _ = sysCfgDb.MasterListCfgGetOne(uid, pvdTimeKey) } // 所有时间都是在操作秒数 now := time.Now().Unix() strs := strings.Split(latest.V, ":") timeStr := latest.V if len(strs) == 3 { timeStr = strs[0] + ":" + strs[1] + ":00" } fmt.Println(timeStr) past := utils.TimeParseStd(timeStr).Unix() if past < now-180*86400 || past > now { past = now } return past } func SetRunTime(uid, pvdTimeKey, val string) { sysCfgDb := db.MasterListCfgDb{} sysCfgDb.Set() sysCfgDb.MasterListCfgUpdate(uid, pvdTimeKey, val) } func GetTpdarenToken(uid string) string { syscfgDb := db.MasterListCfgDb{} syscfgDb.Set() tpdarenAppidData, _ := syscfgDb.MasterListCfgGetOne(uid, "tpdaren_appid") tpdarenAppsecretData, _ := syscfgDb.MasterListCfgGetOne(uid, "tpdaren_appsecret") if tpdarenAppidData == nil || tpdarenAppsecretData == nil { return "" } key := "tpdaren_token_" + tpdarenAppidData.V getString, err := cache.GetString(key) if getString == "" || err != nil { token := tpdaren.TpdarenToken(tpdarenAppidData.V, tpdarenAppsecretData.V) if token == "" { return "" } getString = token cache.SetEx(key, token, 7180) } return getString }