Last active
December 26, 2018 14:58
-
-
Save diegonarducci/8300ae6827baf5c5a4aa6c856fc98c6f to your computer and use it in GitHub Desktop.
Script que vai voltar todas as units já vendidas e ainda não pagas para o vendedor original. usando o outpost_id da UNIT como referencias para saber qual era o vendedor antes de migrar para o usuário [email protected]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SELLER_ID: 10655653 = [email protected] | |
# estamos pegando todas as units que precisam ser pagas, que o seller_id é do usuários central | |
# mas o outpost_id ainda é do usuários antigo, garantido que estamos voltando somente as units | |
# que foram migradas, mas as que forma vendidos pós migração não. | |
units = Unit.where(deleted_at: nil). | |
where(seller_id: 10655653). | |
where.not(outpost_id: 10655653). | |
where(state: ['authorized','completed']). | |
where(blocked: false). | |
where(suspended_at: nil). | |
where(seller_received: false). | |
where(seller_received_confirmed_at: nil). | |
where(payment_version: 2) | |
units.find_each do |unit| | |
old_seller_id = unit.outpost_id | |
unit.update_attribute(:seller_id, old_seller_id) | |
PayUnitWorker.perform_in(10.seconds, unit.id) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍 rev 5