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
|
golang 1.24.3
|
||||||
|
python 3.13.3
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package cardredeemcookie
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
"kami/internal/consts"
|
"kami/internal/consts"
|
||||||
"kami/internal/dao"
|
"kami/internal/dao"
|
||||||
|
"kami/internal/model/do"
|
||||||
"kami/internal/model/entity"
|
"kami/internal/model/entity"
|
||||||
"kami/utility/config"
|
"kami/utility/config"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/duke-git/lancet/v2/pointer"
|
"github.com/duke-git/lancet/v2/pointer"
|
||||||
"github.com/gogf/gf/errors/gerror"
|
"github.com/gogf/gf/errors/gerror"
|
||||||
@@ -27,14 +30,21 @@ func (s *sCardReddemCookie) ScheduleAccount(ctx context.Context, tx gdb.TX) (out
|
|||||||
|
|
||||||
// UnlockAccount 解封临时封禁的账号
|
// UnlockAccount 解封临时封禁的账号
|
||||||
func (s *sCardReddemCookie) UnlockAccount(ctx context.Context, tx gdb.TX) {
|
func (s *sCardReddemCookie) UnlockAccount(ctx context.Context, tx gdb.TX) {
|
||||||
m := dao.V1CardRedeemCookieInfo.Ctx(ctx).DB(config.GetDatabaseV1()).
|
m := dao.V1CardRedeemCookieInfo.Ctx(ctx).DB(config.GetDatabaseV1())
|
||||||
Where(dao.V1CardRedeemCookieInfo.Columns().Status, consts.CardRedeemCookieStatusDailyDisable).
|
|
||||||
WhereLT(dao.V1CardRedeemCookieInfo.Columns().UpdatedAt, gtime.Now().StartOfDay())
|
|
||||||
if tx != nil {
|
if tx != nil {
|
||||||
m = m.TX(tx)
|
m = m.TX(tx)
|
||||||
}
|
}
|
||||||
_, _ = m.Update(gdb.Map{
|
if _, err := m.Where(dao.V1CardRedeemCookieInfo.Columns().Status, consts.CardRedeemCookieStatusDailyDisable).
|
||||||
dao.V1CardRedeemCookieInfo.Columns().Status: consts.CardRedeemCookieStatusNormal,
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user