软质押任务修改
This commit is contained in:
@@ -28,25 +28,12 @@ func NewBindWalletLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BindWa
|
||||
}
|
||||
|
||||
func (l *BindWalletLogic) BindWallet(req *types.EmailKey) (*types.CarvResult, error) {
|
||||
u, err := l.svcCtx.UserModel.FindOneByEmail(l.ctx, req.Email)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrUserNotFound),
|
||||
Message: "email not exist",
|
||||
},
|
||||
}, nil
|
||||
uid, errResult := l.svcCtx.FindUserByEmail(l.ctx, req.Email)
|
||||
if errResult != nil {
|
||||
return errResult, nil
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.WalletModel.FindAddressByUid(l.ctx, u.Id)
|
||||
_, err := l.svcCtx.WalletModel.FindAddressByUid(l.ctx, uid)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return &types.CarvResult{
|
||||
|
||||
@@ -2,7 +2,9 @@ package carv
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"errors"
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
@@ -24,8 +26,32 @@ func NewDownloadAndBindRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DownloadAndBindRoleLogic) DownloadAndBindRole(req *types.EmailKey) (resp *types.CarvResult, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
func (l *DownloadAndBindRoleLogic) DownloadAndBindRole(req *types.EmailKey) (*types.CarvResult, error) {
|
||||
uid, errResult := l.svcCtx.FindUserByEmail(l.ctx, req.Email)
|
||||
if errResult != nil {
|
||||
return errResult, nil
|
||||
}
|
||||
|
||||
return
|
||||
pb, err := l.svcCtx.PromoteBindModel.FindOneByInvitedUid(l.ctx, uid)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return &types.CarvResult{Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
}}, nil
|
||||
}
|
||||
return &types.CarvResult{Result: &types.Result{
|
||||
IsValid: false,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
if pb.IsCreateRole == 0 {
|
||||
return &types.CarvResult{Result: &types.Result{
|
||||
IsValid: false,
|
||||
}}, nil
|
||||
}
|
||||
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: true},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@ package carv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/spf13/cast"
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"time"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
@@ -24,8 +29,51 @@ func NewWalletCheckInLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Wal
|
||||
}
|
||||
}
|
||||
|
||||
func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) (resp *types.CarvResult, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
func (l *WalletCheckInLogic) WalletCheckIn(req *types.EmailKey) (*types.CarvResult, error) {
|
||||
uid, errResult := l.svcCtx.FindUserByEmail(l.ctx, req.Email)
|
||||
if errResult != nil {
|
||||
return errResult, nil
|
||||
}
|
||||
|
||||
return
|
||||
task, err := l.svcCtx.TaskModel.FindDailyPayTask(l.ctx)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrTaskNotFound),
|
||||
Message: "task not exist",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
taskSeq := cast.ToInt(time.Now().Format("20060102"))
|
||||
tp, err := l.svcCtx.TaskProgressModel.FindOneByUidTaskIdTaskSeq(l.ctx, int(uid), task.Id, taskSeq)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: false},
|
||||
}, nil
|
||||
}
|
||||
if tp.Stage >= model.TASK_PROGRESS_WAIT_REWARD {
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: true},
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &types.CarvResult{
|
||||
Result: &types.Result{IsValid: false},
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -76,11 +76,9 @@ func (l *HolderUpdateLogic) HolderUpdate() {
|
||||
} else {
|
||||
// 持有数量变化
|
||||
value = balance - nft.Balance
|
||||
if value != 0 {
|
||||
nft.Balance = balance
|
||||
nft.UpdateSeq = updateSeq
|
||||
err = l.svcCtx.NftHolderModel.Update(l.ctx, nft)
|
||||
}
|
||||
nft.Balance = balance
|
||||
nft.UpdateSeq = updateSeq
|
||||
err = l.svcCtx.NftHolderModel.Update(l.ctx, nft)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -36,6 +36,35 @@ func (l *GetTaskListLogic) GetTaskList(uid int, req *types.GetTaskListReq) (*typ
|
||||
return nil, errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
|
||||
if uid == 0 {
|
||||
resp := &types.GetTaskListResp{}
|
||||
for _, t := range tasks {
|
||||
var totalCount = 1
|
||||
if t.Param != "" {
|
||||
totalCount = cast.ToInt(t.Param)
|
||||
}
|
||||
|
||||
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,
|
||||
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: 0,
|
||||
TotalCount: totalCount,
|
||||
FinishState: model.TASK_PROGRESS_NOT_FINISHED,
|
||||
})
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user