软质押任务修改
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))
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
type ApiKeyCheckMiddleware struct {
|
||||
conf model.NhSystemConfigModel
|
||||
user model.NhUserModel
|
||||
}
|
||||
|
||||
func NewApiKeyCheckMiddleware(conf model.NhSystemConfigModel) *ApiKeyCheckMiddleware {
|
||||
|
||||
@@ -37,12 +37,15 @@ type (
|
||||
}
|
||||
|
||||
NhPromoteBind struct {
|
||||
Id uint `db:"id"`
|
||||
ShareUid uint `db:"share_uid"` // 分享者uid
|
||||
InvitedUid uint `db:"invited_uid"` // 受邀者uid
|
||||
CreateTime uint `db:"create_time"` // 创建时间
|
||||
IsPushUser int8 `db:"is_push_user"` // 是否已推送用户信息
|
||||
IsPushRole int8 `db:"is_push_role"` // 是否已推送绑定游戏账号
|
||||
Id uint `db:"id"`
|
||||
ShareUid uint `db:"share_uid"` // 分享者uid
|
||||
InvitedUid uint `db:"invited_uid"` // 受邀者uid
|
||||
CreateTime uint `db:"create_time"` // 创建时间
|
||||
IsPushUser int8 `db:"is_push_user"` // 是否已推送用户信息
|
||||
IsPushRole int8 `db:"is_push_role"` // 是否已推送绑定游戏账号
|
||||
IsCreateRole int8 `db:"is_create_role"` // 是否已创建角色,0=否,1=已创建
|
||||
IsBindWallet int8 `db:"is_bind_wallet"` // 是否已绑定钱包,0=否,1=已绑定
|
||||
IsOpenSeason int8 `db:"is_open_season"` // 是否已开启赛季,0=否,1=已开启
|
||||
}
|
||||
)
|
||||
|
||||
@@ -88,14 +91,14 @@ func (m *defaultNhPromoteBindModel) FindOneByInvitedUid(ctx context.Context, inv
|
||||
}
|
||||
|
||||
func (m *defaultNhPromoteBindModel) Insert(ctx context.Context, data *NhPromoteBind) (sql.Result, error) {
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, nhPromoteBindRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.ShareUid, data.InvitedUid, data.IsPushUser, data.IsPushRole)
|
||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, nhPromoteBindRowsExpectAutoSet)
|
||||
ret, err := m.conn.ExecCtx(ctx, query, data.ShareUid, data.InvitedUid, data.IsPushUser, data.IsPushRole, data.IsCreateRole, data.IsBindWallet, data.IsOpenSeason)
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (m *defaultNhPromoteBindModel) Update(ctx context.Context, newData *NhPromoteBind) error {
|
||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, nhPromoteBindRowsWithPlaceHolder)
|
||||
_, err := m.conn.ExecCtx(ctx, query, newData.ShareUid, newData.InvitedUid, newData.IsPushUser, newData.IsPushRole, newData.Id)
|
||||
_, err := m.conn.ExecCtx(ctx, query, newData.ShareUid, newData.InvitedUid, newData.IsPushUser, newData.IsPushRole, newData.IsCreateRole, newData.IsBindWallet, newData.IsOpenSeason, newData.Id)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ type (
|
||||
nhTaskModel
|
||||
withSession(session sqlx.Session) NhTaskModel
|
||||
FindTasksByCommunity(ctx context.Context, communityId uint) ([]*NhTask, error)
|
||||
FindDailyPayTask(ctx context.Context) (*NhTask, error)
|
||||
}
|
||||
|
||||
customNhTaskModel struct {
|
||||
@@ -38,6 +39,20 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhTaskModel) FindDailyPayTask(ctx context.Context) (*NhTask, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `status` = 1 and `type` = ? limit 1", nhTaskRows, m.table)
|
||||
var resp NhTask
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, TASKTYPE_DAILY_PAY)
|
||||
switch {
|
||||
case err == nil:
|
||||
return &resp, nil
|
||||
case errors.Is(err, sqlx.ErrNotFound):
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhTaskModel) FindTasksByCommunity(ctx context.Context, communityId uint) ([]*NhTask, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `status` = 1 and community_id = ? order by `sort`", nhTaskRows, m.table)
|
||||
var tasks []*NhTask
|
||||
|
||||
@@ -16,6 +16,7 @@ type (
|
||||
nhTouristBindModel
|
||||
withSession(session sqlx.Session) NhTouristBindModel
|
||||
FindRequirePushUser(ctx context.Context, shareUid uint) ([]NhTouristBindUser, error)
|
||||
FindOneByEmail(ctx context.Context, email string) (*NhTouristBind, error)
|
||||
}
|
||||
|
||||
customNhTouristBindModel struct {
|
||||
@@ -28,6 +29,20 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (m *customNhTouristBindModel) FindOneByEmail(ctx context.Context, email string) (*NhTouristBind, error) {
|
||||
query := fmt.Sprintf("select %s from %s where `email` = ? limit 1", nhTouristBindRows, m.table)
|
||||
var resp NhTouristBind
|
||||
err := m.conn.QueryRowCtx(ctx, &resp, query, email)
|
||||
switch {
|
||||
case err == nil:
|
||||
return &resp, nil
|
||||
case errors.Is(err, sqlx.ErrNotFound):
|
||||
return nil, ErrNotFound
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func (m *customNhTouristBindModel) FindRequirePushUser(ctx context.Context, shareUid uint) ([]NhTouristBindUser, error) {
|
||||
query := fmt.Sprintf("SELECT t2.id, t1.uid FROM nh_tourist_bind t1 JOIN nh_promote_bind t2 ON t1.uid = t2.invited_uid WHERE t2.share_uid = ? AND t2.is_push_role = 0;")
|
||||
var resp []NhTouristBindUser
|
||||
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
"nova_task/internal/config"
|
||||
"nova_task/internal/middleware"
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/types"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
@@ -118,3 +120,24 @@ func (s *ServiceContext) HasBindTwitter(ctx context.Context, uid uint) bool {
|
||||
}
|
||||
return tw.TwitterId != ""
|
||||
}
|
||||
|
||||
func (s *ServiceContext) FindUserByEmail(ctx context.Context, email string) (uint, *types.CarvResult) {
|
||||
u, err := s.UserModel.FindOneByEmail(ctx, email)
|
||||
if err != nil {
|
||||
if !errors.Is(err, model.ErrNotFound) {
|
||||
return 0, &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrDatabaseOperate),
|
||||
Message: "system error",
|
||||
},
|
||||
}
|
||||
}
|
||||
return 0, &types.CarvResult{
|
||||
Error: &types.Error{
|
||||
Code: int(errs.ErrUserNotFound),
|
||||
Message: "email not exist",
|
||||
},
|
||||
}
|
||||
}
|
||||
return u.Id, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user