特朗普头像任务
This commit is contained in:
@@ -44,7 +44,7 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
totalCount = cast.ToInt(t.Param)
|
||||
}
|
||||
|
||||
resp.Tasks = append(resp.Tasks, types.Task{
|
||||
tks := types.Task{
|
||||
Id: t.Id,
|
||||
Title: t.Title,
|
||||
SubTitle: t.SubTitle,
|
||||
@@ -60,7 +60,12 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
HasFinishCount: 0,
|
||||
TotalCount: totalCount,
|
||||
FinishState: model.TASK_PROGRESS_NOT_FINISHED,
|
||||
})
|
||||
}
|
||||
if tks.Type == model.TASKTYPE_TRUMP_HEAD {
|
||||
tks.Params = t.PropertyId
|
||||
}
|
||||
|
||||
resp.Tasks = append(resp.Tasks, tks)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@@ -91,7 +96,7 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
// 计算任务完成数量以及总数
|
||||
hasFinishCount := 0
|
||||
totalCount := 1
|
||||
|
||||
param := t.Param
|
||||
if finishState >= model.TASK_PROGRESS_WAIT_REWARD {
|
||||
// 如果任务状态为待领取奖励, 完成数量等于总数量
|
||||
hasFinishCount = totalCount
|
||||
@@ -126,6 +131,9 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
if hasBindTwitter == 1 {
|
||||
hasFinishCount = 1
|
||||
}
|
||||
|
||||
case model.TASKTYPE_TRUMP_HEAD:
|
||||
param = t.PropertyId
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +154,7 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
Description: t.Description,
|
||||
Points: t.Points,
|
||||
ButtonText: t.ButtonText,
|
||||
Params: t.Param,
|
||||
Params: param,
|
||||
Type: t.Type,
|
||||
Url: t.Url,
|
||||
StartAt: t.StartAt.Time.Format(time.DateTime),
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewGetTaskRewardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Get
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetTaskRewardLogic) GetTaskReward(req *types.TaskIdPath) (*types.GetTaskRewardResp, error) {
|
||||
func (l *GetTaskRewardLogic) GetTaskReward(req *types.GetTaskRewardReq) (*types.GetTaskRewardResp, error) {
|
||||
//uid := cast.ToStringMapInt(l.ctx.Value("data"))["id"]
|
||||
uid := utils.GetUid(l.ctx)
|
||||
task, err := l.svcCtx.TaskModel.FindOne(l.ctx, req.ID)
|
||||
@@ -43,6 +43,22 @@ func (l *GetTaskRewardLogic) GetTaskReward(req *types.TaskIdPath) (*types.GetTas
|
||||
}
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
if task.Type == model.TASKTYPE_TRUMP_HEAD {
|
||||
if req.RoleId == 0 {
|
||||
return nil, errs.New(errs.ErrInvalidParam, "Must select role")
|
||||
}
|
||||
roleUid, err := l.svcCtx.RoleModel.FindRoleUserId(l.ctx, req.RoleId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errs.New(errs.ErrRoleNotFound, "role not found")
|
||||
}
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
if roleUid != uint(uid) {
|
||||
return nil, errs.New(errs.ErrRoleNotFound, "role not found")
|
||||
}
|
||||
}
|
||||
|
||||
var taskSeq int
|
||||
if task.Type == model.TASKTYPE_DAILY_PAY || task.Type == model.TASKTYPE_AMBASSADOR_TASK {
|
||||
taskSeq = cast.ToInt(time.Now().Format("20060102"))
|
||||
@@ -62,6 +78,7 @@ func (l *GetTaskRewardLogic) GetTaskReward(req *types.TaskIdPath) (*types.GetTas
|
||||
return nil, errs.New(errs.ErrTaskAlreadyReward, "task already reward")
|
||||
}
|
||||
|
||||
assetType := consts.GetAssetType(task.RewardType)
|
||||
// 修改状态,增加积分和记录都在事物中执行
|
||||
err = l.svcCtx.DBConn.TransactCtx(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
// 修改状态
|
||||
@@ -70,8 +87,9 @@ func (l *GetTaskRewardLogic) GetTaskReward(req *types.TaskIdPath) (*types.GetTas
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 给予用户奖励
|
||||
err = l.svcCtx.AddUserAssetWithSession(l.ctx, session, uint(uid), consts.AssetType_Points, decimal.NewFromInt(int64(task.Points)), "完成任务:"+task.Title, uint64(task.Id), 0, true)
|
||||
err = l.svcCtx.AddUserAssetWithSession(l.ctx, session, uint(uid), req.RoleId, assetType, task.PropertyId, decimal.NewFromInt(int64(task.Points)), "完成任务:"+task.Title, uint64(task.Id), 0, assetType == consts.AssetType_Points)
|
||||
//err = l.svcCtx.TaskAssetModel.WithSession(session).AddPoint(l.ctx, uint(uid), decimal.NewFromInt(int64(task.Points)))
|
||||
//if err != nil {
|
||||
// return err
|
||||
|
||||
@@ -76,7 +76,7 @@ func (l *VerifyTaskResultLogic) VerifyTaskResult(req *types.VerifyTaskResultReq)
|
||||
}
|
||||
|
||||
case model.TASKTYPE_BIND_DISCORD:
|
||||
case model.TASKTYPE_DAILY_PAY:
|
||||
case model.TASKTYPE_DAILY_PAY, model.TASKTYPE_TRUMP_HEAD:
|
||||
if req.Params == "" {
|
||||
return &types.VerifyTaskResultResp{Finish: false}, nil
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user