fix: 修复获取全部/文件读取/ReqShop/ReqShopReqShop 请求错误
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:
@@ -56,8 +56,13 @@ type ReqShopReq struct {
|
|||||||
func (c *BaseSysUserController) ReqShop(ctx context.Context, req *ReqShopReq) (res *cool.BaseRes, err error) {
|
func (c *BaseSysUserController) ReqShop(ctx context.Context, req *ReqShopReq) (res *cool.BaseRes, err error) {
|
||||||
t := cool.GetAdmin(ctx)
|
t := cool.GetAdmin(ctx)
|
||||||
|
|
||||||
if !playerservice.NewTaskService(uint32(t.UserId)).CanShop() {
|
user := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
||||||
return cool.Fail("不满足申请条件"), nil
|
if user == nil || user.QQ == 0 {
|
||||||
|
return cool.Fail("请先绑定QQ"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
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", "27", "userId", t.UserId).Save()
|
||||||
res = cool.Ok(nil)
|
res = cool.Ok(nil)
|
||||||
|
|||||||
@@ -4,36 +4,30 @@ import (
|
|||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
"blazing/modules/player/model"
|
"blazing/modules/player/model"
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/pointernil/bitset32"
|
"github.com/pointernil/bitset32"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *TaskService) CanShop() bool {
|
func (s *TaskService) CanShop() bool {
|
||||||
|
return s.ShopRequirementError() == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *TaskService) ShopRequirementError() error {
|
||||||
var gg *model.Task
|
var gg *model.Task
|
||||||
|
|
||||||
s.dbm(s.Model).Where("task_id", 500).Scan(&gg)
|
s.dbm(s.Model).Where("task_id", 500).Scan(&gg)
|
||||||
|
if gg == nil || !bitset32.From(gg.Data).Test(80) {
|
||||||
if gg == nil {
|
return errors.New("请先完成勇者任务80")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r := bitset32.From(gg.Data)
|
|
||||||
// 分支未完成时,标记完成并发放奖励
|
|
||||||
if !r.Test(70) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
var ggg *model.Task
|
var ggg *model.Task
|
||||||
s.dbm(s.Model).Where("task_id", 600).Scan(&ggg)
|
s.dbm(s.Model).Where("task_id", 600).Scan(&ggg)
|
||||||
if ggg == nil {
|
if ggg == nil || !bitset32.From(ggg.Data).Test(50) {
|
||||||
return false
|
return errors.New("请先完成试炼任务50")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分支未完成时,标记完成并发放奖励
|
return nil
|
||||||
if !bitset32.From(ggg.Data).Test(50) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取任务信息
|
// 获取任务信息
|
||||||
|
|||||||
Reference in New Issue
Block a user