feat(internal): 优化账号解封逻辑
- 解封今日封禁的账号 - 解封临时封禁的账号 - 添加日志记录解封失败的情况 - 更新 Go 和 Python 版本
This commit is contained in:
2
.lingma/rules/project_rule.md
Normal file
2
.lingma/rules/project_rule.md
Normal file
@@ -0,0 +1,2 @@
|
||||
**添加规则文件可帮助模型精准理解你的编码偏好,如框架、代码风格等**
|
||||
**规则文件只对当前工程生效,单文件限制10000字符。如果无需将该文件提交到远程 Git 仓库,请将其添加到 .gitignore**
|
||||
@@ -1 +1,2 @@
|
||||
golang 1.24.3
|
||||
python 3.13.3
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user