增加社区列表接口,任务相关接口修改
This commit is contained in:
@@ -33,7 +33,12 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
tasks, err := l.svcCtx.TaskModel.FindTasksByCommunity(l.ctx, req.CommunityId)
|
||||
if err != nil {
|
||||
l.Errorw("get task list failed", logx.Field("err", err), logx.Field("communityId", req.CommunityId))
|
||||
return nil, errs.InternalServer(errs.ErrDatabaseOperate, err)
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
|
||||
count, err := l.svcCtx.PromoteBindModel.UserInviteCount(l.ctx, uint(uid))
|
||||
if err != nil {
|
||||
l.Errorw("get user invite count failed", logx.Field("err", err), logx.Field("uid", uid))
|
||||
}
|
||||
|
||||
resp := &types.GetTaskListResp{}
|
||||
@@ -44,25 +49,46 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
}
|
||||
var finishState int8
|
||||
if uid > 0 {
|
||||
tp, err := l.svcCtx.TaskProgressModel.FindOneByUidTaskIdTaskSeq(l.ctx, uid, t.CommunityId, taskSeq)
|
||||
tp, err := l.svcCtx.TaskProgressModel.FindOneByUidTaskIdTaskSeq(l.ctx, uid, t.Id, taskSeq)
|
||||
if err == nil {
|
||||
finishState = tp.Stage
|
||||
}
|
||||
}
|
||||
|
||||
hasFinishCount := 0
|
||||
totalCount := 1
|
||||
if t.Type == model.TASKTYPE_INVITE_USER {
|
||||
totalCount = cast.ToInt(t.Param)
|
||||
hasFinishCount = cast.ToInt(count)
|
||||
}
|
||||
if finishState >= model.TASK_PROGRESS_WAIT_REWARD {
|
||||
hasFinishCount = totalCount
|
||||
}
|
||||
|
||||
if hasFinishCount > totalCount {
|
||||
hasFinishCount = totalCount
|
||||
}
|
||||
|
||||
if hasFinishCount >= totalCount && finishState == model.TASK_PROGRESS_NOT_FINISHED {
|
||||
finishState = model.TASK_PROGRESS_WAIT_VERIFY
|
||||
}
|
||||
|
||||
resp.Tasks = append(resp.Tasks, types.Task{
|
||||
Id: t.Id,
|
||||
Title: t.Title,
|
||||
SubTitle: t.SubTitle,
|
||||
Description: t.Description,
|
||||
Points: t.Points,
|
||||
ButtonText: t.ButtonText,
|
||||
Type: t.Type,
|
||||
Url: t.Url,
|
||||
StartAt: t.StartAt.Time.Format(time.DateTime),
|
||||
EndAt: t.EndAt.Time.Format(time.DateTime),
|
||||
Status: t.Status,
|
||||
FinishState: finishState,
|
||||
Id: t.Id,
|
||||
Title: t.Title,
|
||||
SubTitle: t.SubTitle,
|
||||
Description: t.Description,
|
||||
Points: t.Points,
|
||||
ButtonText: t.ButtonText,
|
||||
Params: t.Param,
|
||||
Type: t.Type,
|
||||
Url: t.Url,
|
||||
StartAt: t.StartAt.Time.Format(time.DateTime),
|
||||
EndAt: t.EndAt.Time.Format(time.DateTime),
|
||||
Sort: t.Sort,
|
||||
HasFinishCount: hasFinishCount,
|
||||
TotalCount: totalCount,
|
||||
FinishState: finishState,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user