Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

tmp
huangjiajun pirms 2 nedēļām
vecāks
revīzija
1edab7380a
4 mainītis faili ar 32 papildinājumiem un 3 dzēšanām
  1. +10
    -1
      app/hdl/comm/hdl_comm.go
  2. +0
    -1
      app/hdl/hdl_callback_advertising.go
  3. +21
    -0
      app/utils/time.go
  4. +1
    -1
      go.mod

+ 10
- 1
app/hdl/comm/hdl_comm.go Parādīt failu

@@ -119,6 +119,7 @@ func AccessRecords(c *gin.Context) {

get, err1 := cache.GetBit(cacheKey, user.Id)
if err1 != nil || get == 0 {
// 更新页面记录
recordsDb := implement.NewEggAccessRecordsDb(db.Db)
exist, err := recordsDb.EggAccessRecordsExist(user.Id, date, req.Index)
if err != nil {
@@ -136,12 +137,20 @@ func AccessRecords(c *gin.Context) {
return
}
}

_, err = cache.SetBit(cacheKey, user.Id, 1)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
// 更新浏览记录总表
year, week := time.Now().ISOWeek()
totalDb := implement.NewEggAccessTotalDb(db.Db)
_, err = totalDb.EggAccessTotalAddOrDefault(user.Id, year, week)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

} else {
e.OutErr(c, e.ERR, errors.New("无效的重复请求").Error())
return


+ 0
- 1
app/hdl/hdl_callback_advertising.go Parādīt failu

@@ -125,7 +125,6 @@ func commDoing(c *gin.Context, platform, transId, userId, extra, primeRit, uniqI
Platform: platform,
Oid: transId,
Uid: utils.StrToInt(userId),
Extra: extra,
SpaceId: primeRit,
UniqId: uniqId,
CreateAt: time.Now(),


+ 21
- 0
app/utils/time.go Parādīt failu

@@ -79,6 +79,11 @@ func TimeParseStd(src string) time.Time {
return t
}

func TimeParseDateStd(src string) time.Time {
t, _ := TimeParse("2006-01-02", src)
return t
}

func TimeStdParseUnix(src string) int64 {
t, err := TimeParse("2006-01-02 15:04:05", src)
if err != nil {
@@ -245,3 +250,19 @@ func GetStartOfWeek(t time.Time) time.Time {
func GetZeroTime(d time.Time) time.Time {
return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, d.Location())
}

// GetWeekInfoByDate 获取周数、开始时间、结束时间
func GetWeekInfoByDate(dateStr string) (string, string, string, string) {
date := TimeParseDateStd(dateStr)
year, week := date.ISOWeek()
location, _ := time.LoadLocation("Asia/Shanghai")
// 计算给定年份1月1日是星期几
startOfYear := time.Date(year, time.January, 1, 0, 0, 0, 0, location)
daysOffset := int(startOfYear.Weekday()) - int(time.Monday) + 1
// 计算给定年份的第一周的开始日期
firstWeekStart := startOfYear.AddDate(0, 0, -daysOffset+1)
// 计算给定周的开始日期
weekStart := firstWeekStart.AddDate(0, 0, (week-1)*7)
weekEnd := weekStart.AddDate(0, 0, 6)
return IntToStr(year), IntToStr(week), weekStart.Format("2006-01-02"), weekEnd.Format("2006-01-02")
}

+ 1
- 1
go.mod Parādīt failu

@@ -32,7 +32,7 @@ require (
)

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241214095356-fdac2df9537f
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241216083317-8f7f975c0482
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241215151712-d253a63d8ae1
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5


Notiek ielāde…
Atcelt
Saglabāt