大使任务逻辑
This commit is contained in:
@@ -25,7 +25,7 @@ func NewBindWalletLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindWa
|
||||
}
|
||||
|
||||
func (l *BindWalletLogic) BindWallet(req *types.EmailKey) (resp *types.CarvResult, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
l.svcCtx.UserModel.FindOneByEmail(l.ctx, req.Email)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,12 +41,16 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
l.Errorw("get user invite count failed", logx.Field("err", err), logx.Field("uid", uid))
|
||||
}
|
||||
|
||||
var isAmbassador, hasBindTwitter int
|
||||
|
||||
resp := &types.GetTaskListResp{}
|
||||
for _, t := range tasks {
|
||||
// 任务序列号
|
||||
taskSeq := 0
|
||||
if t.Type == model.TASKTYPE_DAILY_PAY {
|
||||
taskSeq = cast.ToInt(time.Now().Format("20060102"))
|
||||
}
|
||||
// 读取任务完成状态
|
||||
var finishState int8
|
||||
if uid > 0 {
|
||||
tp, err := l.svcCtx.TaskProgressModel.FindOneByUidTaskIdTaskSeq(l.ctx, uid, t.Id, taskSeq)
|
||||
@@ -55,20 +59,53 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
}
|
||||
}
|
||||
|
||||
// 计算任务完成数量以及总数
|
||||
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
|
||||
} else {
|
||||
// 分任务类型处理
|
||||
switch t.Type {
|
||||
case model.TASKTYPE_INVITE_USER:
|
||||
totalCount = cast.ToInt(t.Param)
|
||||
hasFinishCount = cast.ToInt(count)
|
||||
case model.TASKTYPE_AMBASSADOR_TASK:
|
||||
if isAmbassador == 0 {
|
||||
if l.svcCtx.IsAmbassador(l.ctx, uint(uid), 0) {
|
||||
isAmbassador = 1
|
||||
} else {
|
||||
isAmbassador = 2
|
||||
}
|
||||
}
|
||||
if isAmbassador == 1 {
|
||||
hasFinishCount = 1
|
||||
} else {
|
||||
hasFinishCount = 0
|
||||
hasFinishCount = model.TASK_PROGRESS_NOT_ALLOWED
|
||||
}
|
||||
case model.TASKTYPE_BIND_TWITTER:
|
||||
if hasBindTwitter == 0 {
|
||||
if l.svcCtx.HasBindTwitter(l.ctx, uint(uid)) {
|
||||
hasBindTwitter = 1
|
||||
} else {
|
||||
hasBindTwitter = 2
|
||||
}
|
||||
}
|
||||
if hasBindTwitter == 1 {
|
||||
hasFinishCount = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 超过数量的显示任务要求的数量即可
|
||||
if hasFinishCount > totalCount {
|
||||
hasFinishCount = totalCount
|
||||
}
|
||||
|
||||
// 数量达标,且状态为未完成,则显示待校验状态
|
||||
if hasFinishCount >= totalCount && finishState == model.TASK_PROGRESS_NOT_FINISHED {
|
||||
finishState = model.TASK_PROGRESS_WAIT_VERIFY
|
||||
}
|
||||
|
||||
@@ -62,14 +62,7 @@ func (l *VerifyTaskResultLogic) VerifyTaskResult(req *types.VerifyTaskResultReq)
|
||||
// todo: 校验用户是否完成该任务
|
||||
switch task.Type {
|
||||
case model.TASKTYPE_BIND_TWITTER:
|
||||
tw, err := l.svcCtx.TwitterModel.FindOneByUid(l.ctx, uint(uid))
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
return &types.VerifyTaskResultResp{Finish: false}, nil
|
||||
}
|
||||
if tw.TwitterId == "" {
|
||||
if !l.svcCtx.HasBindTwitter(l.ctx, uint(uid)) {
|
||||
return &types.VerifyTaskResultResp{Finish: false}, nil
|
||||
}
|
||||
case model.TASKTYPE_INVITE_USER:
|
||||
@@ -91,6 +84,10 @@ func (l *VerifyTaskResultLogic) VerifyTaskResult(req *types.VerifyTaskResultReq)
|
||||
return &types.VerifyTaskResultResp{Finish: false}, nil
|
||||
}
|
||||
}
|
||||
case model.TASKTYPE_AMBASSADOR_TASK:
|
||||
if !l.svcCtx.IsAmbassador(l.ctx, uint(uid), 0) {
|
||||
return &types.VerifyTaskResultResp{Finish: false}, nil
|
||||
}
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user