feat: slected after buy
This commit is contained in:
@@ -99,6 +99,11 @@ func (s *Service) BuyAvatar(ctx context.Context, userID int64, avatarID string)
|
||||
`INSERT INTO user_avatars (user_id, avatar_id) VALUES (?, ?)`, userID, avatarID); err != nil {
|
||||
return err
|
||||
}
|
||||
// خرید = مالکیت + انتخابِ خودکار.
|
||||
if _, err := tx.ExecContext(ctx,
|
||||
`UPDATE users SET selected_avatar = ? WHERE id = ?`, avatarID, userID); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,11 @@ func (s *Service) BuyCarpet(ctx context.Context, userID int64, carpetID string)
|
||||
`INSERT INTO user_carpets (user_id, carpet_id) VALUES (?, ?)`, userID, carpetID); err != nil {
|
||||
return err
|
||||
}
|
||||
// خرید = مالکیت + انتخابِ خودکار.
|
||||
if _, err := tx.ExecContext(ctx,
|
||||
`UPDATE users SET selected_carpet = ? WHERE id = ?`, carpetID, userID); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
|
||||
@@ -274,6 +274,11 @@ func (s *Service) BuyCard(ctx context.Context, userID int64, cardID string) erro
|
||||
`INSERT INTO user_cards (user_id, card_id) VALUES (?, ?)`, userID, cardID); err != nil {
|
||||
return err
|
||||
}
|
||||
// خرید = مالکیت + انتخابِ خودکار (بهعنوانِ پیشفرض فعال شود).
|
||||
if _, err := tx.ExecContext(ctx,
|
||||
`UPDATE users SET selected_card = ? WHERE id = ?`, cardID, userID); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,11 @@ func (s *Service) BuyFrame(ctx context.Context, userID int64, frameID string) er
|
||||
`INSERT INTO user_frames (user_id, frame_id) VALUES (?, ?)`, userID, frameID); err != nil {
|
||||
return err
|
||||
}
|
||||
// خرید = مالکیت + انتخابِ خودکار.
|
||||
if _, err := tx.ExecContext(ctx,
|
||||
`UPDATE users SET selected_frame = ? WHERE id = ?`, frameID, userID); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Commit()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user