feat(internal): 优化账号解封逻辑

- 解封今日封禁的账号
- 解封临时封禁的账号
- 添加日志记录解封失败的情况
- 更新 Go 和 Python 版本
This commit is contained in:
danial
2025-05-15 01:23:44 +08:00
parent ea7dd3c438
commit 3a79ec7ed5
3 changed files with 19 additions and 6 deletions

View File

@@ -0,0 +1,2 @@
**添加规则文件可帮助模型精准理解你的编码偏好如框架代码风格等**
**规则文件只对当前工程生效单文件限制10000字符如果无需将该文件提交到远程 Git 仓库请将其添加到 .gitignore**

View File

@@ -1 +1,2 @@
golang 1.24.3
python 3.13.3

View File

@@ -2,11 +2,14 @@ package cardredeemcookie
import (
"context"
"github.com/gogf/gf/v2/os/glog"
"github.com/gogf/gf/v2/os/gtime"
"kami/internal/consts"
"kami/internal/dao"
"kami/internal/model/do"
"kami/internal/model/entity"
"kami/utility/config"
"time"
"github.com/duke-git/lancet/v2/pointer"
"github.com/gogf/gf/errors/gerror"
@@ -27,14 +30,21 @@ func (s *sCardReddemCookie) ScheduleAccount(ctx context.Context, tx gdb.TX) (out
// UnlockAccount 解封临时封禁的账号
func (s *sCardReddemCookie) UnlockAccount(ctx context.Context, tx gdb.TX) {
m := dao.V1CardRedeemCookieInfo.Ctx(ctx).DB(config.GetDatabaseV1()).
Where(dao.V1CardRedeemCookieInfo.Columns().Status, consts.CardRedeemCookieStatusDailyDisable).
WhereLT(dao.V1CardRedeemCookieInfo.Columns().UpdatedAt, gtime.Now().StartOfDay())
m := dao.V1CardRedeemCookieInfo.Ctx(ctx).DB(config.GetDatabaseV1())
if tx != nil {
m = m.TX(tx)
}
_, _ = m.Update(gdb.Map{
dao.V1CardRedeemCookieInfo.Columns().Status: consts.CardRedeemCookieStatusNormal,
})
if _, err := m.Where(dao.V1CardRedeemCookieInfo.Columns().Status, consts.CardRedeemCookieStatusDailyDisable).
WhereLT(dao.V1CardRedeemCookieInfo.Columns().UpdatedAt, gtime.Now().StartOfDay()).Update(do.V1CardRedeemCookieInfo{
Status: consts.CardRedeemCookieStatusNormal,
}); err != nil {
glog.Error(ctx, "解封今日封禁的账号失败", err)
}
if _, err := m.Where(dao.V1CardRedeemCookieInfo.Columns().Status, consts.CardRedeemCookieStatusTmpDisable).
WhereLT(dao.V1CardRedeemCookieInfo.Columns().UpdatedAt, gtime.Now().Add(-time.Minute*10)).Update(do.V1CardRedeemCookieInfo{
Status: consts.CardRedeemCookieStatusNormal,
}); err != nil {
glog.Error(ctx, "解封临时封禁的账号失败", err)
}
return
}