- 有历史签到数据 → 优先使用历史中的真实地址和经纬度 - 无历史签到数据 → 保底从 signPlaceSelected 提取管理员配置的范围信息
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"github.com/gogf/gf/v2/container/gvar"
|
||||
"github.com/google/uuid"
|
||||
"github.com/samber/oops"
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/tidwall/match"
|
||||
"resty.dev/v3"
|
||||
)
|
||||
@@ -457,11 +458,9 @@ func (c *CpdailyAutoSignTask) ParseFormJson(ctx context.Context, rawJson map[str
|
||||
histSignPhotoUrl := ""
|
||||
histIsMalposition := ""
|
||||
|
||||
// 只有有真实的已签到历史数据时,才从历史数据中提取地址和经纬度
|
||||
// 否则 rows 中包含的是管理员圈定的范围配置数据,不是用户实际签到地址
|
||||
// signPlaceSelected 始终是管理员圈定范围,不应使用
|
||||
// 优先使用历史签到数据(真实地址),无历史时保底使用管理员配置的范围信息
|
||||
if hasHistory {
|
||||
// 先从 longitude/latitude/position/signAddress 提取
|
||||
// 从历史签到数据中提取用户真实的地址和经纬度
|
||||
if lon := histRows["longitude"]; lon != nil && lon.String() != "" {
|
||||
if lat := histRows["latitude"]; lat != nil && lat.String() != "" {
|
||||
histLatAndLon = lon.String() + "," + lat.String()
|
||||
@@ -488,6 +487,24 @@ func (c *CpdailyAutoSignTask) ParseFormJson(ctx context.Context, rawJson map[str
|
||||
}
|
||||
}
|
||||
}
|
||||
// 无历史签到数据时,保底使用管理员配置的范围信息
|
||||
if histLatAndLon == "" && histAddress == "" {
|
||||
if sps := rows["signPlaceSelected"]; sps != nil && sps.String() != "" && sps.String() != "[]" {
|
||||
placeArr := gjson.Parse(sps.String()).Array()
|
||||
if len(placeArr) > 0 {
|
||||
place := placeArr[0]
|
||||
lng := place.Get("longitude").String()
|
||||
lat := place.Get("latitude").String()
|
||||
addr := place.Get("address").String()
|
||||
if lng != "" && lat != "" {
|
||||
histLatAndLon = lng + "," + lat
|
||||
}
|
||||
if addr != "" {
|
||||
histAddress = addr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dto := &formtype.CpTaskFormItem{
|
||||
Title: "经纬度",
|
||||
|
||||
@@ -535,11 +535,9 @@ func (c *CpdailySleepCheckTask) ParseFormJson(ctx context.Context, rawJson map[s
|
||||
histSignPhotoUrl := ""
|
||||
histIsMalposition := ""
|
||||
|
||||
// 只有有真实的已签到历史数据时,才从历史数据中提取地址和经纬度
|
||||
// 否则 rows 中包含的是管理员圈定的范围配置数据,不是用户实际签到地址
|
||||
// signPlaceSelected 始终是管理员圈定范围,不应使用
|
||||
// 优先使用历史签到数据(真实地址),无历史时保底使用管理员配置的范围信息
|
||||
if hasHistory {
|
||||
// 先从 longitude/latitude/position/signAddress 提取
|
||||
// 从历史签到数据中提取用户真实的地址和经纬度
|
||||
if lon := histRows["longitude"]; lon != nil && lon.String() != "" {
|
||||
if lat := histRows["latitude"]; lat != nil && lat.String() != "" {
|
||||
histLatAndLon = lon.String() + "," + lat.String()
|
||||
@@ -566,6 +564,24 @@ func (c *CpdailySleepCheckTask) ParseFormJson(ctx context.Context, rawJson map[s
|
||||
}
|
||||
}
|
||||
}
|
||||
// 无历史签到数据时,保底使用管理员配置的范围信息
|
||||
if histLatAndLon == "" && histAddress == "" {
|
||||
if sps := rows["signPlaceSelected"]; sps != nil && sps.String() != "" && sps.String() != "[]" {
|
||||
placeArr := gjson.Parse(sps.String()).Array()
|
||||
if len(placeArr) > 0 {
|
||||
place := placeArr[0]
|
||||
lng := place.Get("longitude").String()
|
||||
lat := place.Get("latitude").String()
|
||||
addr := place.Get("address").String()
|
||||
if lng != "" && lat != "" {
|
||||
histLatAndLon = lng + "," + lat
|
||||
}
|
||||
if addr != "" {
|
||||
histAddress = addr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dto := &formtype.CpTaskFormItem{
|
||||
Title: "经纬度",
|
||||
|
||||
Reference in New Issue
Block a user