Compare commits

...

2 Commits

Author SHA1 Message Date
liaoyulong
5a12750f11 新增通用方法 2025-09-24 15:40:06 +08:00
ayflying
6139b4f722 修改更新文件 2025-09-22 10:21:38 +08:00
2 changed files with 29 additions and 20 deletions

View File

@@ -2,15 +2,16 @@ package cmd
import (
"context"
"os"
"path"
"time"
"github.com/ayflying/utility_go/pkg"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
"github.com/gogf/gf/v2/os/gcfg"
"github.com/gogf/gf/v2/os/gcmd"
"github.com/gogf/gf/v2/os/gctx"
"os"
"path"
"time"
)
type serverCfg struct {
@@ -41,22 +42,6 @@ var (
getFileName, err := g.Cfg("hack").Get(ctx, "gfcli.build.name")
Filename := getFileName.String()
////获取架构
//getArch, err := g.Cfg("hack").Get(ctx, "gfcli.build.arch")
//Arch := getArch.String()
//if Arch == "" {
// Arch = "amd64"
//}
//
////获取操作系统
//getSystem, err := g.Cfg("hack").Get(ctx, "gfcli.build.system")
//System := getSystem.String()
//
//if System == "" {
// System = "linux"
//}
//var systemName = System + "_" + Arch
//获取版本号
getVersion, err := g.Cfg("hack").Get(ctx, "gfcli.build.version")
Version := getVersion.String()

View File

@@ -1,8 +1,9 @@
package tools
import (
"github.com/gogf/gf/v2/os/gtime"
"time"
"github.com/gogf/gf/v2/os/gtime"
)
type timeMod struct {
@@ -128,3 +129,26 @@ func (m *timeMod) ExcelTime2Time(excelTime string) time.Time {
timeNew, _ := time.ParseInLocation(layout, excelTime, time.Local)
return timeNew
}
// 指定时刻刷新
// 判断当前是否可领取
// createdTime 刷新时刻
// lastRwdTime 上次领取时间
// now 当前时间
func (m *timeMod) CheckIsBeRwd(createdTime, lastRwdTime time.Time, _now ...time.Time) bool {
now := time.Now()
if len(_now) > 0 {
now = _now[0]
}
//今天的刷新时间
refreshToday := time.Date(now.Year(), now.Month(), now.Day(),
createdTime.Hour(), createdTime.Minute(), createdTime.Second(),
0, createdTime.Location())
// 如果今天还没到刷新时间,则刷新时间应是昨天
if now.Before(refreshToday) {
refreshToday = refreshToday.AddDate(0, 0, -1)
}
// 判断上次领取时间是否在刷新时间之前
// 如果是,则说明还没领过,可以领取
return lastRwdTime.Before(refreshToday)
}