Compare commits

...

3 Commits

Author SHA1 Message Date
becomer d454ecc7cf fix: 无历史时保底使用管理员配置的签到范围信息
ci/woodpecker/tag/build Pipeline was successful
- 有历史签到数据 → 优先使用历史中的真实地址和经纬度
- 无历史签到数据 → 保底从 signPlaceSelected 提取管理员配置的范围信息
2026-07-04 01:04:10 +08:00
becomer 7ede964c4c fix: 未签到任务表单中地址和经纬度仍错误使用管理员配置数据
ci/woodpecker/tag/build Pipeline was successful
- ParseFormJson: 完全移除 signPlaceSelected 提取(始终是管理员范围数据)
- ParseFormJson: 将 longitude/latitude/position/signAddress 提取全部包进 if hasHistory
- QueryFormByTitle: 已签到(相同 instanceWid)时将自身 rows 设为 historyRows
- 确保无历史数据的未签到任务不会错误显示管理员范围名称(如"7")
2026-07-04 00:59:33 +08:00
becomer 4b50af3ae0 fix: woodpecker 只应在推送 tag 时触发,移除 push event 2026-07-04 00:51:27 +08:00
3 changed files with 66 additions and 69 deletions
-2
View File
@@ -1,6 +1,4 @@
when:
- event: push
branch: [main, master]
- event: tag
branch: [v*]
+33 -33
View File
@@ -227,11 +227,10 @@ func (c *CpdailyAutoSignTask) QueryFormByTitle(ctx context.Context, titleGlob st
// 尝试从已签到的历史任务中获取历史数据用于预填充
signedMatch := findMatchTitle(signedTasks)
if signedMatch != nil {
// 如果已签到任务与当前匹配任务是同一个,不设置 historyRows
// 因为同一任务的 signPlaceSelected 包含的是管理员圈定范围数据,不是实际签到地址
if matchTask != nil && signedMatch["signInstanceWid"] != nil && matchTask["signInstanceWid"] != nil &&
signedMatch["signInstanceWid"].String() == matchTask["signInstanceWid"].String() {
// 不设置 historyRows,让后面从历史月份查找
// 任务已签到(同一个 instanceWid),自身 rows 中的 longitude/latitude/position 就是用户自己提交的数据
result["historyRows"] = gvar.New(formDatas)
} else {
histResp, histErr := c.client.R().
SetBody(map[string]*gvar.Var{
@@ -459,10 +458,38 @@ func (c *CpdailyAutoSignTask) ParseFormJson(ctx context.Context, rawJson map[str
histSignPhotoUrl := ""
histIsMalposition := ""
// 只有有真实的已签到历史数据时,才从 signPlaceSelected 提取
// 否则 signPlaceSelected 包含的是管理员圈定范围的数据(范围名称可能为纯数字如"7"),不是实际签到地址
// 优先使用历史签到数据(真实地址),无历史时保底使用管理员配置的范围信息
if hasHistory {
if sps := histRows["signPlaceSelected"]; sps != nil && sps.String() != "" && sps.String() != "[]" {
// 从历史签到数据中提取用户真实的地址和经纬度
if lon := histRows["longitude"]; lon != nil && lon.String() != "" {
if lat := histRows["latitude"]; lat != nil && lat.String() != "" {
histLatAndLon = lon.String() + "," + lat.String()
}
}
if histAddress == "" {
if pos := histRows["position"]; pos != nil && pos.String() != "" {
histAddress = pos.String()
}
}
if histAddress == "" {
if addr := histRows["signAddress"]; addr != nil && addr.String() != "" {
histAddress = addr.String()
}
}
if photo := histRows["signPhotoUrl"]; photo != nil && photo.String() != "" {
histSignPhotoUrl = photo.String()
}
if mal := histRows["isMalposition"]; mal != nil {
if mal.Int() == 1 {
histIsMalposition = "是"
} else {
histIsMalposition = "否"
}
}
}
// 无历史签到数据时,保底使用管理员配置的范围信息
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]
@@ -478,33 +505,6 @@ func (c *CpdailyAutoSignTask) ParseFormJson(ctx context.Context, rawJson map[str
}
}
}
if histLatAndLon == "" {
if lon := histRows["longitude"]; lon != nil && lon.String() != "" {
if lat := histRows["latitude"]; lat != nil && lat.String() != "" {
histLatAndLon = lon.String() + "," + lat.String()
}
}
}
if histAddress == "" {
if pos := histRows["position"]; pos != nil && pos.String() != "" {
histAddress = pos.String()
}
if histAddress == "" {
if addr := histRows["signAddress"]; addr != nil && addr.String() != "" {
histAddress = addr.String()
}
}
}
if photo := histRows["signPhotoUrl"]; photo != nil && photo.String() != "" {
histSignPhotoUrl = photo.String()
}
if mal := histRows["isMalposition"]; mal != nil {
if mal.Int() == 1 {
histIsMalposition = "是"
} else {
histIsMalposition = "否"
}
}
dto := &formtype.CpTaskFormItem{
Title: "经纬度",
+33 -34
View File
@@ -281,11 +281,10 @@ func (c *CpdailySleepCheckTask) QueryFormByTitle(ctx context.Context, titleGlob
// 无论当前任务是否已签到,都尝试获取历史数据
signedMatch := findMatchTitle(signedTasks)
if signedMatch != nil {
// 如果已签到任务与当前匹配任务是同一个,不设置 historyRows
// 因为同一任务的 signPlaceSelected 包含的是管理员圈定范围数据,不是实际签到地址
if matchTask != nil && signedMatch["signInstanceWid"] != nil && matchTask["signInstanceWid"] != nil &&
signedMatch["signInstanceWid"].String() == matchTask["signInstanceWid"].String() {
// 不设置 historyRows,让后面从历史月份查找
// 任务已签到(同一个 instanceWid),自身 rows 中的 longitude/latitude/position 就是用户自己提交的数据
result["historyRows"] = gvar.New(datas)
} else {
histResp, histErr := c.client.R().
SetBody(map[string]*gvar.Var{
@@ -536,10 +535,38 @@ func (c *CpdailySleepCheckTask) ParseFormJson(ctx context.Context, rawJson map[s
histSignPhotoUrl := ""
histIsMalposition := ""
// 只有有真实的已签到历史数据时,才从 signPlaceSelected 提取
// 否则 signPlaceSelected 包含的是管理员圈定范围的数据(范围名称可能为纯数字如"7"),不是实际签到地址
// 优先使用历史签到数据(真实地址),无历史时保底使用管理员配置的范围信息
if hasHistory {
if sps := histRows["signPlaceSelected"]; sps != nil && sps.String() != "" && sps.String() != "[]" {
// 从历史签到数据中提取用户真实的地址和经纬度
if lon := histRows["longitude"]; lon != nil && lon.String() != "" {
if lat := histRows["latitude"]; lat != nil && lat.String() != "" {
histLatAndLon = lon.String() + "," + lat.String()
}
}
if histAddress == "" {
if pos := histRows["position"]; pos != nil && pos.String() != "" {
histAddress = pos.String()
}
}
if histAddress == "" {
if addr := histRows["signAddress"]; addr != nil && addr.String() != "" {
histAddress = addr.String()
}
}
if photo := histRows["signPhotoUrl"]; photo != nil && photo.String() != "" {
histSignPhotoUrl = photo.String()
}
if mal := histRows["isMalposition"]; mal != nil {
if mal.Int() == 1 {
histIsMalposition = "是"
} else {
histIsMalposition = "否"
}
}
}
// 无历史签到数据时,保底使用管理员配置的范围信息
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]
@@ -555,34 +582,6 @@ func (c *CpdailySleepCheckTask) ParseFormJson(ctx context.Context, rawJson map[s
}
}
}
// 降级:直接从 longitude/latitude/position 字段取
if histLatAndLon == "" {
if lon := histRows["longitude"]; lon != nil && lon.String() != "" {
if lat := histRows["latitude"]; lat != nil && lat.String() != "" {
histLatAndLon = lon.String() + "," + lat.String()
}
}
}
if histAddress == "" {
if pos := histRows["position"]; pos != nil && pos.String() != "" {
histAddress = pos.String()
}
if histAddress == "" {
if addr := histRows["signAddress"]; addr != nil && addr.String() != "" {
histAddress = addr.String()
}
}
}
if photo := histRows["signPhotoUrl"]; photo != nil && photo.String() != "" {
histSignPhotoUrl = photo.String()
}
if mal := histRows["isMalposition"]; mal != nil {
if mal.Int() == 1 {
histIsMalposition = "是"
} else {
histIsMalposition = "否"
}
}
dto := &formtype.CpTaskFormItem{
Title: "经纬度",