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) {
|
||||
t := cool.GetAdmin(ctx)
|
||||
|
||||
if !playerservice.NewTaskService(uint32(t.UserId)).CanShop() {
|
||||
return cool.Fail("不满足申请条件"), nil
|
||||
user := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
||||
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()
|
||||
res = cool.Ok(nil)
|
||||
|
||||
@@ -4,36 +4,30 @@ import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/pointernil/bitset32"
|
||||
)
|
||||
|
||||
func (s *TaskService) CanShop() bool {
|
||||
return s.ShopRequirementError() == nil
|
||||
}
|
||||
|
||||
func (s *TaskService) ShopRequirementError() error {
|
||||
var gg *model.Task
|
||||
|
||||
s.dbm(s.Model).Where("task_id", 500).Scan(&gg)
|
||||
|
||||
if gg == nil {
|
||||
return false
|
||||
if gg == nil || !bitset32.From(gg.Data).Test(80) {
|
||||
return errors.New("请先完成勇者任务80")
|
||||
}
|
||||
|
||||
r := bitset32.From(gg.Data)
|
||||
// 分支未完成时,标记完成并发放奖励
|
||||
if !r.Test(70) {
|
||||
return false
|
||||
}
|
||||
var ggg *model.Task
|
||||
s.dbm(s.Model).Where("task_id", 600).Scan(&ggg)
|
||||
if ggg == nil {
|
||||
return false
|
||||
if ggg == nil || !bitset32.From(ggg.Data).Test(50) {
|
||||
return errors.New("请先完成试炼任务50")
|
||||
}
|
||||
|
||||
// 分支未完成时,标记完成并发放奖励
|
||||
if !bitset32.From(ggg.Data).Test(50) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取任务信息
|
||||
|
||||
Reference in New Issue
Block a user