nft task reward

This commit is contained in:
lianghuanjie
2024-12-31 20:39:02 +08:00
parent 029289e84c
commit ea86ab71e8
20 changed files with 945 additions and 170 deletions

View File

@@ -15,7 +15,7 @@ type (
NhTaskNftStakeModel interface {
nhTaskNftStakeModel
withSession(session sqlx.Session) NhTaskNftStakeModel
StakeNft(ctx context.Context, uid uint, tokens []string) error
StakeNft(ctx context.Context, uid uint, roleId uint64, tokens []string) error
UnStakeNft(ctx context.Context, uid uint, token string) error
FindByUid(ctx context.Context, uid uint) ([]NhTaskNftStake, error)
AllStakeNft(ctx context.Context) ([]NhTaskNftStake, error)
@@ -52,10 +52,10 @@ func (m *customNhTaskNftStakeModel) UnStakeNft(ctx context.Context, uid uint, to
return err
}
func (m *customNhTaskNftStakeModel) StakeNft(ctx context.Context, uid uint, tokens []string) error {
insertOrUpdate := fmt.Sprintf("INSERT INTO %s (`uid`, `token_id`, `state`) VALUES (?, ?, 1) ON DUPLICATE KEY UPDATE `state` = 1", m.table)
func (m *customNhTaskNftStakeModel) StakeNft(ctx context.Context, uid uint, roleId uint64, tokens []string) error {
insertOrUpdate := fmt.Sprintf("INSERT INTO %s (`uid`, `token_id`, `role_id`, `state`) VALUES (?, ?, ?, 1) ON DUPLICATE KEY UPDATE `role_id` = ?, `state` = 1", m.table)
for _, token := range tokens {
_, err := m.conn.ExecCtx(ctx, insertOrUpdate, uid, token)
_, err := m.conn.ExecCtx(ctx, insertOrUpdate, uid, token, roleId, roleId)
if err != nil {
return err
}