feat: 添加商城权限自动回收机制
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -54,8 +54,9 @@ type ReqShopReq struct {
|
||||
|
||||
func (c *BaseSysUserController) ReqShop(ctx context.Context, req *ReqShopReq) (res *cool.BaseRes, err error) {
|
||||
t := cool.GetAdmin(ctx)
|
||||
baseSysUserService := service.NewBaseSysUserService()
|
||||
|
||||
user := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
||||
user := baseSysUserService.GetPerson(uint32(t.UserId))
|
||||
if user == nil || user.QQ == 0 {
|
||||
return cool.Fail("请先绑定QQ"), nil
|
||||
}
|
||||
@@ -63,7 +64,7 @@ func (c *BaseSysUserController) ReqShop(ctx context.Context, req *ReqShopReq) (r
|
||||
if err := playerservice.NewTaskService(uint32(t.UserId)).ShopRequirementError(); err != nil {
|
||||
return cool.Fail(err.Error()), nil
|
||||
}
|
||||
cool.DBM(&model.BaseSysUserRole{}).Data("roleId", "27", "userId", t.UserId).Save()
|
||||
cool.DBM(&model.BaseSysUserRole{}).Data("roleId", service.ShopRoleID, "userId", t.UserId).Save()
|
||||
res = cool.Ok(nil)
|
||||
return
|
||||
}
|
||||
@@ -83,19 +84,24 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq)
|
||||
|
||||
res = &SessionRes{}
|
||||
|
||||
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
||||
baseSysUserService := service.NewBaseSysUserService()
|
||||
t1 := baseSysUserService.GetPerson(uint32(t.UserId))
|
||||
|
||||
res.UserID = int(t1.ID)
|
||||
playerinfo := blazing.NewUserService(uint32(t1.ID)).Info.Person(uint32(t1.ID))
|
||||
if playerinfo != nil {
|
||||
res.IsReg = 1
|
||||
if t1.DepartmentID == 35 { ///抢先服玩家,3天没登录衰退
|
||||
|
||||
if playerinfo.UpdateTime.AddDate(0, 0, 3).Before(gtime.Now()) {
|
||||
if playerinfo.UpdateTime.AddDate(0, 0, 3).Before(gtime.Now()) {
|
||||
if t1.DepartmentID == 35 { ///抢先服玩家,3天没登录衰退
|
||||
t1.DepartmentID = 1
|
||||
service.NewBaseSysUserService().SetdepartmentId(uint32(t1.ID), 1)
|
||||
baseSysUserService.SetdepartmentId(uint32(t1.ID), 1)
|
||||
}
|
||||
}
|
||||
if playerinfo.UpdateTime.AddDate(0, 0, 7).Before(gtime.Now()) {
|
||||
err = baseSysUserService.CancelShopPermission(ctx, t1.ID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
res.PetID = dict.NewDictInfoService().GetShiny()
|
||||
|
||||
@@ -29,6 +29,8 @@ type BaseSysUserService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
const ShopRoleID uint = 27
|
||||
|
||||
// Person 方法 返回不带密码的用户信息
|
||||
func (s *BaseSysUserService) Person(userId uint) (res gdb.Record, err error) {
|
||||
m := cool.DBM(s.Model)
|
||||
@@ -70,6 +72,19 @@ func (s *BaseSysUserService) SetdepartmentId(userId, departmentId uint32) (res *
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (s *BaseSysUserService) CancelShopPermission(ctx context.Context, userId uint) error {
|
||||
_, err := cool.DBM(model.NewBaseSysUserRole()).
|
||||
Where("userId", userId).
|
||||
Where("roleId", ShopRoleID).
|
||||
Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return NewBaseSysPermsService().RefreshPerms(ctx, userId)
|
||||
}
|
||||
|
||||
func (s *BaseSysUserService) DuihuanFreeGold(userId uint32, gold, free int64) {
|
||||
m := cool.DBM(s.Model).Where("id", userId)
|
||||
m.Data(g.Map{
|
||||
|
||||
Reference in New Issue
Block a user