nft质押道具发放
This commit is contained in:
@@ -67,7 +67,7 @@ func (l *GetTaskRewardLogic) GetTaskReward(req *types.TaskIdPath) (*types.GetTas
|
||||
return err
|
||||
}
|
||||
// 给予用户奖励
|
||||
err = l.svcCtx.TaskAssetModel.WithSession(session).AddUserPoint(l.ctx, uid, task.Points)
|
||||
err = l.svcCtx.TaskAssetModel.WithSession(session).AddPoint(l.ctx, uid, task.Points)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,12 +2,15 @@ package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"github.com/spf13/cast"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"nova_task/internal/model"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"nova_task/internal/pkg/utils"
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type StakeNftLogic struct {
|
||||
@@ -32,5 +35,35 @@ func (l *StakeNftLogic) StakeNft(req *types.StakeNftList) error {
|
||||
return errs.New(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
|
||||
for _, tokenId := range req.TokenIds {
|
||||
var sns []int8
|
||||
var propertyId string
|
||||
if utils.IsBigTarot(tokenId) {
|
||||
sns = []int8{1, 2}
|
||||
propertyId = "402505"
|
||||
} else {
|
||||
sns = []int8{1}
|
||||
propertyId = "402605"
|
||||
}
|
||||
for _, sn := range sns {
|
||||
_, err = l.svcCtx.StakePropertyModel.Insert(l.ctx, &model.NhNftStakeProperty{
|
||||
Uid: uid,
|
||||
RoleId: int64(req.RoleId),
|
||||
TokenId: cast.ToUint(tokenId),
|
||||
PropertyId: "",
|
||||
Sn: sn,
|
||||
})
|
||||
if err != nil {
|
||||
errMySQL := new(mysql.MySQLError)
|
||||
if errors.As(err, &errMySQL) {
|
||||
switch errMySQL.Number {
|
||||
case 1062:
|
||||
default:
|
||||
l.Errorw("insert stake property failed", logx.Field("err", err), logx.Field("uid", uid), logx.Field("tokenId", tokenId), logx.Field("propertyId", propertyId))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return errs.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user